Skip to content

Instantly share code, notes, and snippets.

@jdhom
Last active February 21, 2018 19:29
Show Gist options
  • Save jdhom/6b9ed19b587efa8bb29aefcb006bf7c3 to your computer and use it in GitHub Desktop.
Save jdhom/6b9ed19b587efa8bb29aefcb006bf7c3 to your computer and use it in GitHub Desktop.
Powershell Core on macos

Was really pretty simple and just worked ;). Note, .NetCore is really important, I accidently installed AWSPowerShell instead of AWSPowerShell.NetCore, which installs but throws exceptions. Duh.

Set-AWSCredential -ProfileName 'SOME-PROFILE.ROLE'

Set-DefaultAWSRegion -Region 'us-east-1'

note: Turns out running the Set- commands above makes the aws commandlets disappear. Use explicit region/profile on individual commands

# brew install powershell core (based on .net core)
brew tap caskroom/cask && brew cask install powershell

# load powershell
pwsh

# install aws cmdlets && set some defaults
Install-Module AWSPowerShell.NetCore

# explicit, common, parameters (profile/region)
Get-DDBTable -TableName SOME-TABLENAME  -ProfileName 'SOME-PROFILE.ROLE' -Region 'us-east-1'

# use splatting as an easy way to pass/change parameters common to cmdlets
$CommonParams = @{"ProfileName"="SOME-PROFILE.ROLE";"Region"="us-east-1"}
Get-DDBTable -TableName SOME-TABLENAME @CommonParams

# change profile and get nonprod table
$CommonParams.ProfileName='SOME-OTHER-PROFILE.ROLE'
Get-DDBTable -TableName SOME-TABLENAME @CommonParams

# bask in the glory of powershell core on linux/macos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment