question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked AllenLiu-MSFT answered

Unable to run powershell script or commands in MDT Task Sequence

I have a two line Powershell script I want to run at the end of an MDT Task Sequence. I don't get an error, it just doesn't run. I've tried running the commands in a Powershell Task Sequence step and also as an Application. Here's what I need to run:

$Filelocation = "c:\OfflineJoinDomain\" + $env:computername + ".txt"
cmd /c Djoin.exe /requestodj /loadfile "$FileLocation" /windowspath %windir% /localos

Here is my Application command line: powershell.exe -ExecutionPolicy Bypass - File %DEPLOYROOT%\Applications\DJoin.ps1

I've also tried running it as a Command Line step:
Powershell.exe -ExecutionPolicy Bypass -Command "$Filelocation = 'c:\OfflineJoinDomain\' + $env:computername + '.txt'; cmd /c Djoin.exe /requestodj /loadfile '$FileLocation' /windowspath %windir% /localos"

Also, I've tried using %OSDComputerName% instead of $env:computername.

Any ideas?

mem-mdt
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.

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ answered

Solved it. I was a simple issue of replacing '$FileLocation' with $FileLocation

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.

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

Thank you for posting in Microsoft Q&A forum and thank you for the update and we're glad the problem is solved now.

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.