Score:0

How to execute powershell scripts from MDT?

cn flag

I have created MDT environment with PSD Extension by following these steps.

There is a default step for running a powershell script(Configure).

configure

I duplicated that and created Configure1. configure1

And created a script in DeploymentShare scripts folder. scripts

Just added below content to the powershell script I created.

#PSDConfigure1.ps1
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

But it seems, the above content is not applied on the machine after task sequence.

Please suggest how to execute the powershell scripts.

Score:0
sg flag

It could be because of execution policy.

Try this:

 %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Noninteractive -Executionpolicy bypass -Noprofile -File {pathToFile.ps1}
Sara June avatar
cn flag
Still same, it is not executing
Sara June avatar
cn flag
It seems it is executed only if I keep in custo taks section.
sg flag
@SaraJune, do you have proof the script is executing? Have you looked at the SMSTS log? I'd look in there to see if its being triggered properly. Default log location is here: %WINDIR%\TEMP\DeploymentLogs, and here is the technet article... https://docs.microsoft.com/en-us/troubleshoot/mem/configmgr/troubleshooting-reference
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.