Windows 10 run a powershell command like a batch file

  • Thread starter Thread starter SlickRCBD
  • Start date Start date
S

SlickRCBD

I am working as a temp on a Windows 7 to Windows 10 migration team.

We've encountered a problem with some software, and a solution has been found that requires us to execute a a single command with PowerShell.

However, the command is extremely long and complex, and very easy to make a typo. As an added hickup, some of the older laptops are being replaced at this time, and we are using crossover cables to migrate the users' files instead of clogging the network, which temporarily takes them offline as the new laptops shut off their wifi when we plug in an Ethernet cable for some aggravating reason (the old win7 laptops stay online via wifi).



Is there any way to make a batch file on a flash drive we can double-click on in order to execute the PowerShell command and fix the installs?

Saving it as a .bat file does not work. Saving it as a .PS1 file tells us that it is blocked for security purposes.

These are fresh images, and the PowerShell fixes the autoconfig, so any group policy changes won't be pushed until after the command is executed, plus we probably want to leave the security in place after the migration as the users are working from home due to COVID and bringing their laptops in for the migration or laptop replacement (and I'm stuck sanitizing the computers).


So, how can I make a file to double-click on and execute a single command in PowerShell the way I could for decades in command.com or cmd.com with a .bat file?


BTW, I'm furloughed for the next few days next week while the higher up IT guys are trying to fix the issue, but I thought I'd take the initiative and ask how we can implement the solution at hand easier.

The best I've come up with was to save the command as a .txt file, and copy and paste using Notepad.

This is exactly the type of thing that if it was done with commmand.com or cmd.com I would have made a .bat file and been done with it.

Continue reading...
 
Back
Top