none
Getting error "Property 'EnablePrivileges' cannot be found on this object; make sure it exists and is settable." RRS feed

  • Question

  • Hi

    I am new to powershell scripting.. I herewith attaching my code.. I am getting the subjected error message "Property 'EnablePrivileges' cannot be found on this object; make sure it exists  and is settable."

    # Config

    $hname = hostname 

    $Foldername = "c:\temp"

    $Year = get-date -f yyyy

    $nmonth = get-date -f MMMM

    $date = get-date -f dd

    $month = get-date -f MM

     

    #Mapping Drive 

    #Replace \\servername\sharename

    (new-object -com WScript.Network).MapNetworkDrive("x:","\\servername\sharename")

     

    #create folder

    $path = "x:\" +  $hname + "\" + $Year + "\" + $nmonth

    if (!(Test-Path $path))

    {

    [IO.Directory]::CreateDirectory($path)

    }

     

    $path = "x:\" + $hname + "\" + $Year + "\" + $nmonth + "\"

    # do not edit

    $exportFileName = (get-date -f ddMMyyyyhhmmss_) + $hname + "_Application" +  ".evt"

    $logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq "Application"}

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logFile.backupeventlog($path + $exportFileName)

    $logfile.cleareventlog()

     

    $exportFileName = (get-date -f ddMMyyyyhhmmss_) + $hname + "_Security" +  ".evt"

    $logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq "Security"}

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logFile.backupeventlog($path + $exportFileName)

    $logfile.cleareventlog()

     

    $exportFileName = (get-date -f ddMMyyyyhhmmss_) + $hname + "_System" +  ".evt"

    $logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq "System"}

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logFile.backupeventlog($path + $exportFileName)

    $logfile.cleareventlog()

     

    $exportFileName = (get-date -f ddMMyyyyhhmmss_) + $hname + "_Setup" +  ".evt"

    $logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq "Setup.evtx"}

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logFile.backupeventlog($path + $exportFileName)

    $logfile.cleareventlog()

     

    $exportFileName = (get-date -f ddMMyyyyhhmmss_) + $hname + "_ForwardedEvents" +  ".evt"

    $logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq "ForwardedEvents"}

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logfile.PSBase.Scope.Options.EnablePrivileges = $true

    $logFile.backupeventlog($path + $exportFileName)

    $logfile.cleareventlog()

     

    #Disconnect the mapped drive

    (new-object -com WScript.Network).RemoveNetworkDrive("x:")

     

    Kindly help me to solve my error.

     

    Thanks in advance... 

    Tuesday, August 16, 2011 8:07 AM

Answers

  • Hi Muniappan ,
     
    This forum is specifically for matters dealing with Microsoft Project.  I suggest you try to find a more appropriate forum that deals with PowerShell problems.
     
    Mike Glen
    Project MVP
    Tuesday, August 16, 2011 8:13 AM
    Moderator