Tinus EngOps Wiki


OpsaC - Operating as PowerShell code



PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View Tinus IT Wiki

View my Photo Website

Start Powershell Script

tags: PowerShell categories: PowerShell-Basic

Table of Contents

Start PowerShell

Start a PowerShell-Script with a CMD-Script, to test if there is no output in the host.

%~dp0 expands to current directory path of the running batch file. %~n0 expands to the running batch file.

@echo off
rem ---------------------------------------------------------------------------- *
rem Description: Start PS-Script
rem Author     : Martin Walther
rem ---------------------------------------------------------------------------- *

rem Path: %~dp0 Script: %~n0
set log=%~dp0%~n0.log
set script=%~dp0%~n0.ps1
echo %log%
echo %script%

echo %date% %time% > %log%
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass %script% >> %log%
echo %date% %time% >> %log%
notepad %log%

See also

[ Top ] [ Blog ]