I am trying to write a pretty simple script using the invoke-command to edit a registry key that already exist. My issue that there are no errors when I run the script and it returns as a success but the change isn't made on the remote computer.
$Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl\"
$Name = "CrashDumpEnabled"
$Value = "1"
$RComputers = Get-Content "C:\temp\computerlist.txt"
ForEach ($Computer in $Rcomputers)
{
If (test-connection -ComputerName $computer -Count 1 -Quiet)
{
$Results = Invoke-Command $Computer -ScriptBlock {
Try
{
Param($Path,$Name,$Value) Set-ItemProperty -path $path -Name $Name -Value $Value -ErrorAction 'Stop' -ArgumentList $Path,$Property,$Name
}
Catch
{
$status = "Failed"
}
Finally
{
$status = "Success"
}}}
else{
$status = "Unreachable"
}}
New-Object -TypeName PSObject -Property @{
'Computer' = $computer
'Status' = $status}
$results | Out-File "C:\temp\Registry Report.txt"