Run PSADT as user without admin prompt

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?

Hi,

I believe it is a SCCM problem not a script problem. Do you have an option with SCCM “run with admin rights”?

Thanks,

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…

2 Likes