Running Multiple Commands/Script


hello,

i'm total powershell noob. i've been working on getting few things work little more automatically. have 3 commands run individually, i'm not sure how combine them intelligence.

the commands are:

copy-item \\hostname\serverprereqs$ -destination c:\serverprereqs -recurse

install-windowsfeature -configurationfilepath c:\serverprereqs\sccm_features_roles.xml -source c:\serverprereqs\sxs

copy-item \\hostname\sql2012patches$ -destination c:\serverprereqs -recurse

i run them individually. first 1 takes 10 minutes due copying on wan connection. there anyway can set run line line, knowing first line has finish before second can run successfully?

hi nwebb,

yes there is! can create script file (a simple txt file ending .ps1 instead of .txt)and write down 3 lines. each line, append "-erroraction stop" (without quotes). powershell commandline call script this:

. c:\examplefolder\script.ps1

or if it's stored in current path ...

. .\script.ps1

cheers,
fred


there's no place 127.0.0.1



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file