/bundles/itninjaweb/img/Breadcrumb_cap_w.png
HI

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   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

0
Ummmmmmmmmmm...maybe because
Property
S-1-5-21-152799110-1058532297-3105840818-1000
does not exist in the path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff
Answered 07/09/2010 by: VBScab
Red Belt

Please log in to comment