Remove-ItemProperty problem (Double absurd cancellation of a registry entry)
HI
I wrote this script:
I run it thus:
but I get:
Why?
THANKS
BYE
I wrote this script:
param($RemovedSID,$RemAccNameDel)
function KeyAndItemDeleted ($StartKey)
{
if ($StartKey -eq 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff') {
Remove-ItemProperty -LiteralPath $StartKey -Name $RemovedSID -WhatIf
}
else {
Remove-Item $StartKey'\'$RemovedSID -WhatIf
}
}
if (('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff.'+$RemovedSID)) {
KeyAndItemDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff'
}
I run it thus:
powershell -ExecutionPolicy Unrestricted -file "D:\Users\xxx\Documents\b.ps1" "S-1-5-21-152799110-1058532297-3105840818-1000" "AccountNameDeleted"
but I get:
WhatIf: Performing operation "Remove Property" on target "Element: HKEY_LOCAL_M
ACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\Purge
AtNextLogoff Property: S-1-5-21-152799110-1058532297-3105840818-1000".
Remove-ItemProperty : Property S-1-5-21-152799110-1058532297-3105840818-1000 do
es not exist in the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Current
Version\NetCache\PurgeAtNextLogoff.
In D:\Users\xxx\Documents\b.ps1:7 car:31
+ Remove-ItemProperty <<<< -LiteralPath $StartKey -Name $RemovedSID
-WhatIf
+ CategoryInfo : InvalidArgument: (S-1-5-21-152799...3105840818-1
000:String) [Remove-ItemProperty], PSArgumentException
+ FullyQualifiedErrorId : System.Management.Automation.PSArgumentException
,Microsoft.PowerShell.Commands.RemoveItemPropertyCommand
Why?
THANKS
BYE
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
anonymous_9363
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.