question

Draconna avatar image
0 Votes"
Draconna asked GarthJones-9654 commented

Trouble with deploying a powershell script package

Hello, I have a 1 line powershell script I am trying to deploy to a test machine via packages. I have tested the script on my own computer locally and it is working. It is supposed to copy a icon to the my desktop. The trouble is when I try to run it through sccm. I am not sure if it is the command line. I have tried a few different commands so far.

Not knowing which is best, I tried:

copysierra.ps1

Powershell.exe -ExecutionPolicy ByPass -copysierra.PS1

"%Windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command .\copysierra.ps1


Here is my script:

201445-image.png


mem-cm-general
image.png (35.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Garth avatar image
0 Votes"
Garth answered GarthJones-9654 commented

The problem is you are copying the file from a unc, which the local system doesn't have access to. Include the file with the PowerShell script and copy it from the cache.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is this the cache? C:\Windows\ccmcache

Thanks, good to know. I ended up doing this through group policy instead

0 Votes 0 ·

Correct that is the right folder location. But keep in mind that you will not know the subfolder location so you will need to use the ".\" path option.

0 Votes 0 ·
AllenLiu-MSFT avatar image
0 Votes"
AllenLiu-MSFT answered

Hi, @ChristopherWhalen-6797

Thank you for posting in Microsoft Q&A forum.

You may refer to Jason's article to use a bat file to copy files to clients easily.
https://home.memftw.com/copying-files-to-clients-using-configmgr/



If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.