You can execute a PowerShell script from a batch file. But before execution, you need to set up proper PowerShell execution policy as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
## Create a batch file that will execute a powershell script @' @ECHO OFF PowerShell.exe -ExecutionPolicy Bypass -File myscript.ps1 PAUSE '@ > myscript.bat ## Create a powershell script that prints system info @' Get-WmiObject win32_baseboard; Get-WmiObject Win32_Bios; Get-WmiObject win32_physicalmemory ` | Select Manufacturer,Banklabel,Configuredclockspeed,Devicelocator,Capacity,Serialnumber; Get-ComputerInfo OSName, OsArchitecture '@ > myscript.ps1 ## Execute the batch file start-process "cmd.exe" "myscript.bat" |