teamfox201
asked on
Delete computer from SCCM in WinPE
Hello ,
I am running the script below which works fine if I run it from my desktop, but when I add it to a task sequence I get the following error when it runs from WinPE and I am not sure how to fix it.
Line: 21
Char: 1
Error: Permission denied: 'GetObject'
Code: 800A0046
I am running the script below which works fine if I run it from my desktop, but when I add it to a task sequence I get the following error when it runs from WinPE and I am not sure how to fix it.
Line: 21
Char: 1
Error: Permission denied: 'GetObject'
Code: 800A0046
SiteServer = "*******"
provSiteCode = "*******"
GetProviderAccount = "*******"
GetProviderPassword = "*******"
strComputer=InputBox("Please enter the computer name")
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
objLocator.Security_.AuthenticationLevel = 6
Set objSMS = objLocator.ConnectServer(SiteServer , "root/sms/site_" & provSiteCode, GetProviderAccount, GetProviderPassword)
'get the resource ID of the computer
intResourceID = GetResourceID(strComputer)
'Remove ResourceID
Set objResource = GetObject( "WinMgmts:\\" & SiteServer & "\root\SMS\site_" & provSiteCode & ":SMS_R_System.ResourceID=" & cint (intResourceID))
objResource.Delete_
'wscript.echo "Deleted " & strComputer & "(" & intResourceID & ")"
Function GetResourceID(strComputerName)
Set colResourceIDs = objSMS.ExecQuery _
("select ResourceID from SMS_R_System where Name = '" & strComputer & "'")
for each objResID in colResourceIDs
GetResourceID = objResID.ResourceID
next
End Function
ASKER
So now I am getting:
Error when trying to delete the Computer Object. Error:424 - Object required.
Error when trying to delete the Computer Object. Error:424 - Object required.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked! Thank you sooooooo much!
Open in new window