I am trying to get the SCCM agent uninstalled on a VM through VCO & Powershell Host. If its already done by someone, can you please share the worfkflow?
Hi,
could you try Run Script in Guest workflow and here just use sccm uninstaller "C:\Windows\ccmsetup\ccmsetup.exe" /uninstall where "/uninstall" will be attribute for command in this case "programPath" inParameter. I can upload my workflow if you are interested.
Cheers
Appreciate your reply. Can you please upload the workflow?
How are you removing the agent entries in SCCM Console? Our windows team is complaining about orphaned objects in DB if we just uninstall the agent. I got some scripts which can be used to cleanup, they are working fine if I execute the below command manually on DEM worker (with SCCM PS modules). However when I tried to do it through VCO it fails(unable to connect to SCCM PS drive). Appreciate if you can give some insight. Please find the attached scripts.
.\ManageCMClients.ps1 –CMsiteCode "site" –CMSiteServer "SCCMserver" –DeviceList "VMName" –Action Remove –ClientSiteCode "site" -VerboseLogging TestLog -ServiceRequest "1234"
Error from VCO:
PowerShellInvocationError: Errors found while executing script
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObjectSearcher.Initialize()
at System.Management.ManagementObjectSearcher.Get()
at Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlConnectionManager.Connect(String configMgrServerPath)
at Microsoft.ConfigurationManagement.PowerShell.Provider.CMDriveInfo.CreateConnectionManager()
at Microsoft.ConfigurationManagement.PowerShell.Provider.CMDriveInfo.Connect()
at Microsoft.ConfigurationManagement.PowerShell.Provider.CMDriveProvider.NewDrive(PSDriveInfo drive)
at System.Management.Automation.SessionStateInternal.ValidateDriveWithProvider(DriveCmdletProvider driveProvider, PSDriveInfo drive, CmdletProviderContext context, Boolean resolvePathIfPossible)
(Dynamic Script Module name : invokeScript#14)
Hi,
as I asked our Client team they have some scripts they run against AD, if client PC is disabled, they removed entry from DB, otherwise if is agent incative, they will wait 90 days and then auto removed agent from db as well.
About WF, I can share it, but have to prepare it a little.
About the rest, I am no so familiar with SCCM cmd-lets to be more helpfull, sorry.