Search code examples
windowspowershellamazon-web-servicesaws-powershell

How can I make a macro to run a few PowerShell commands one after the other?


I am using Amazon Web Service Powershell extension. I have multiple commands I want to run after each other like this:

PS C:\g> Write-S3Object -BucketName "user-staging" -Key "index.html" -File "index.html"
PS C:\g> Write-S3Object -BucketName 'user-staging' -KeyPrefix 'lib/pagedown' -Folder 'lib/pagedown' -SearchPattern '*.js'

How can I combine these into a macro, batch file or something similar so I can run them all just with one simple command such as:

PS C:\g> publish-files

Solution

  • You need to create a PowerShell script file. Basically the same as a batch file, but with a .ps1 extension.