Avatar of wajhiuddin
wajhiuddin
 asked on

MDT Task Sequence

I am new to MDT and need to add following jobs in to the task sequences
1)enable bit locker
2)Ask for a computer name
3)Run a script  in powershell
I am able to capture and deploy reference image with no problem but just need to know how to add these jobs in to the task sequences
and need some assistances please
Windows OS

Avatar of undefined
Last Comment
wajhiuddin

8/22/2022 - Mon
aravind anche

You can do all these in custom settings
right click deployment share> properties> rules

for computer name
SkipComputerName=NO

For powershell script
Add it in task sequence
Double click the TS
on task sequence tab
select after which  step you want to run the script highlight it >Add>genearal>run powershell script

For enable bitlocker
follow the below link
http://eddiejackson.net/wp/?p=11333
https://community.spiceworks.com/how_to/112239-enable-bitlocker-during-mdt-deployment-non-domain
wajhiuddin

ASKER
To run a powwershell script I now there is an option to run but I don't know what to put in to the box
Power Sheill Scirpt  and parameters. ??
I haveUntitled.png a .ps1 which I want to run ?
aravind anche

Where is is power shell script?
Is it in the script folder of deployment share?
If so
in power shell script column of TS which is image
"PowerShell.exe -File "%SCRIPTROOT%\yourfilename.ps1"

Also what is purpose of the script, some scripts need to have execution policy  bypass
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
wajhiuddin

ASKER
"PowerShell.exe -File "%SCRIPTROOT%\yourfilename.ps1"
Are "on right place ?
aravind anche

Did that work?
wajhiuddin

ASKER
haven't tried yet , I just want to make sure it's correct, there are three qutations (") in the whole string of command and I wanted to make sure it's correct. I have to deploy the image and then see if script runs . which will take soem time probably about 40 minitues.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aravind anche

or you can just %SCRIPTROOT%YORFILE.PS1
wajhiuddin

ASKER
Adding this command "PowerShell.exe -File "%SCRIPTROOT%\yourfilename.ps1"
I get an erorr messag "The run powershell Script action has error that mus tbe resolved.....?
ASKER CERTIFIED SOLUTION
aravind anche

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
wajhiuddin

ASKER
yes Script runs fine
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
wajhiuddin

ASKER
ok it took it this time %SCRIPTROOT%\yourfilename.ps1
Whtats the best way to test beside deploy a whole image ?
aravind anche

i always test power shell scripts on Vm and check its making necessary changes
wajhiuddin

ASKER
thats the great idea but unfortunately we aren't setup that way, will have VMs setup in the future
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
wajhiuddin

ASKER
OK I see script ran and it greated a folder whihc it suppose to do but it wasn't sucessful because it need to set escution policy
aravind anche

then set execution policy bypass

powershell.exe - -executionpolicy bypass -noexit -file "%ScriptRoot%\yourfile.ps1"
wajhiuddin

ASKER
I get the error message "Run PowerShell Action has one or more error that must be......."
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
aravind anche

powershell -NoProfile -ExecutionPolicy Bypass -file %ScriptRoot%\yourfile.ps1
wajhiuddin

ASKER
and this will run execuriont policy unrestricted ?
aravind anche

yes
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
wajhiuddin

ASKER
Deployment was failed because script failed.
It runs perfectly fine when I had just %ScriptRoot%\yourfile.ps1
it just had policy restricted I ran another PowerShell script  right before my script with following command
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -force
It has to be run as admin but looks like Task Sequence is not running this command as an admin.
My  script rans(it creartes a folder "Temp") but not  successful because policy was still restricted?
Please see my script which runs absolutely fine with unrestricted policy
So the problem I have I can't have PowerShell run as unrestricted
Thanks
ProtTest.ps1.txt
wajhiuddin

ASKER
the error I have is Unable to locate script powershell -NoProfile-ExecutionPolicy Bypass-file
aravind anche

Can you try running
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

before running script
Your help has saved me hundreds of hours of internet surfing.
fblack61
wajhiuddin

ASKER
Thanks for your wonderful support