I am trying to run a SCCM package that is script to uninstall a list of printers from a users machine. Unfortunately I am in a bit of a catch 22 and I have ran into my deadline for completing this. In a bit of a pickle and seeing f anyone can assist me.
If I run the script from a blank *.ps1 I run into the set-execution policy restriction. I have tried just running the *.ps1 and also with the following command line:
powershell.exe -executionpolicy Bypass -nologo -noninteractive -file .\YSoftScript.ps1
If I run the script from PSADT with SCCM 2012 package settings to run with user rights I get credential prompts.
Any way to assist me with this?
This is my code:
$Content = Get-Content -Path â$dirFiles\Printers.txtâ
$Printers = [IO.File]::ReadAllText("$dirFiles\Printers.txt")
foreach ($Printers in $Content) {
Get-Printer | select name | Where-Object {$_.Name -like â$Printersâ} | Remove-Printer
Write-Output âRemoved $Printersâ
}
If I run this package with admin rights it uninstalls the printers perfectly since my current account has admin rights. If I do it from another machine it doesnât uninstall anything because itâs running from my credentials not the local user. Thoughts?
Agree with Francois. Check your default client settings (In the SCCM Console --> Administration \ Client Settings \ ). Open up the default client settings and the Computer Agent menu. Check the setting âInstall permissionsâ. Sounds like yours might be set to âOnly administratorsâ, or perhaps âOnly administrators and primary usersâ.
So I also ran into similar issue where the PSADT was prompting for UAC and weâve got our Client Settings â Computer Agent Install Permission set to âOnly administrators and Primary Usersâ on the ConfigMgr. I then looked at my application deployment type â User Experience and found that the Installation behaviour was set to Install for system if resource is device, otherwise install for user â> I just changed the deployment type to âInstall for Systemâ and PSADT worked flawlessly!!
Hope this helps someone out thereâŚ