Running a powershell command via batch or command that is restricted

I had to run a powershell module that I found remotely to remove some pinned applications in Windows 7. I also wanted it to run remotely, and not have to log on to each PC to do so. To kick off a powershell script, I had to add this to a command file:

REM KICK OFF POWERSHELL STUFF
xcopy "\\domain.com\software\Non-Licensed\scripts\kiosk\Set-PinnedApplications.psm1" C:\temp\
powershell "Set-ExecutionPolicy Unrestricted"
powershell \\domain.com\software\Non-Licensed\scripts\kiosk\Remove_Taskbar_Shortcuts.ps1

The .ps1 file leads to this:

Import-Module C:\temp\Set-PinnedApplications.psm1
Set-PinnedApplication -Action UnPinFromTaskBar -FilePath "C:\Users\kiosk\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Internet Explorer.lnk"
Set-PinnedApplication -Action UnPinFromTaskBar -FilePath "C:\Users\kiosk\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Windows Explorer.lnk"
Set-PinnedApplication -Action UnPinFromTaskBar -FilePath "C:\Users\kiosk\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Windows Media Player.lnk"

So it allows me to remove the pinned applications. If you want to view the module (Set-PinnedApplications.psm1) I used off technet it is here:
https://gallery.technet.microsoft.com/scriptcenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750
You would just copy that content into: Set-PinnedApplications.psm1

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

  

  

  

*