Have this working with invoke command but not as local command.
The commands with the # was working on my desktop but I run this script on the server. So I needed to convert the commands to local commands
[pre]
$Results += $(“” | Out-String)
$Results += ‘Server TGCS012’ | out-string
try
{
#$results += invoke-command -computer TGCS012 -scriptblock {reg delete “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager” /v PendingFileRenameOperations /f} -ea Stop
#$results += invoke-command -computer TGCS012 -scriptblock {(Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager’ -Name PendingFileRenameOperations ).PendingFileRenameOperations} -ea Stop
$results += reg delete “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager” /v PendingFileRenameOperations /f
$results += (Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager’ -Name PendingFileRenameOperations ).PendingFileRenameOperations
}
catch { $Results += $_.exception.message}
[/pre]
reg : ERROR: The system was unable to find the specified registry key or value.
At line:7 char:13
- $results += reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\C …
-
- CategoryInfo : NotSpecified: (ERROR: The syst…y key or value.:String) , RemoteException
- FullyQualifiedErrorId : NativeCommandError
Get-ItemProperty : Property PendingFileRenameOperations does not exist at path
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager.
At line:8 char:14
- … results += (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYST …
-
- CategoryInfo : InvalidArgument: (PendingFileRenameOperations:String) [Get-ItemProperty], PSArgumentException
- FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
PS C:\Util> $results
The operation completed successfully.
Server TGCS012
Any ideas
Thank you
Tom