I can find my way around this shit but, this has me stuffed.
Am trying to list out reserved instances in AWS using th eGet-EC2ReservedInstance cmdlet, but, no dice. at all.
The filter directive has as applicable value where state can be payment-pending | active | payment-failed | retired etc
Get-EC2ReservedInstance -Filter state=Active -ProfileName myProfile -Region ap-southeast-2
Get-EC2ReservedInstance : The filter 'State=Active' is invalid
At line:1 char:1
+ Get-EC2ReservedInstance -Filter State=Active -ProfileName myProfile -Region ap-s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Amazon.PowerShe...dInstanceCmdlet:GetEC2ReservedInstanceCmdlet) [Get-EC2
ReservedInstance], InvalidOperationException
+ FullyQualifiedErrorId : Amazon.EC2.AmazonEC2Exception,Amazon.PowerShell.Cmdlets.EC2.GetEC2ReservedInstanceCmdlet
I know state is of 'string' type ; and no number of permutations / combinations has me able to return a successful result. I know state is valid as when i run the command without =Active, it returns nothing ....
Advice appreciated.
Anyone know Powershell? Querying AWS with PS
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Anyone know Powershell? Querying AWS with PS
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Re: Anyone know Powershell? Querying AWS with PS
Get-EC2ReservedInstance -ProfileName myProfile -Region ap-southeast-2 | ?{$_.state -eq 'active'};
pity its not using the implicit 'filter' though.
pity its not using the implicit 'filter' though.
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Re: Anyone know Powershell? Querying AWS with PS
nup, couldn't make -Filter play
landed on Get-EC2ReservedInstance -Region ap-southeast-2 -ProfileName myProfile | select InstanceType,InstanceCount,State,End | ?{$_.state -eq 'active'} | sort End,InstanceType | Out-File ${filepath}RIList.csv
landed on Get-EC2ReservedInstance -Region ap-southeast-2 -ProfileName myProfile | select InstanceType,InstanceCount,State,End | ?{$_.state -eq 'active'} | sort End,InstanceType | Out-File ${filepath}RIList.csv
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Re: Anyone know Powershell? Querying AWS with PS
Never used it before but Amazon has a page here
https://aws.amazon.com/powershell/
https://aws.amazon.com/powershell/
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Re: Anyone know Powershell? Querying AWS with PS
yeah, like with alot of AWS stuff its pretty light on mate. i've figured it out and have another thing emailing me now so all good ; for reference ;
# *****************************************************************************************************************
# ****** Weekly Run script to check for users > 90 days old in AWS ******
# ****** ******
# ****** Created By Greg W 12/01/2017 ******
# ****** Modified By ******
# ****** Runs from C:\AWS\PS\ folder on ******
# ****** Scheduled Task to run weekly ******
# ****** AWS Logon Variables set using Set-AWSCredentials -AccessKey xyz -SecretKey abc -StoreAs -Whatever ******
# ****** These must be set on a per environment basis on the server where this PS runs. ******
# *****************************************************************************************************************
# Global Variables
$filepath = "C:\AWS\Reports\"
$mailtoo = "recipient@whatever.com"
$mailfrom = "sender@whatever.com"
$smtpserver = "smtpserver"
#DEV Users not logged in > 90 days
#Local Variable for DEV
$mailsubject = "DEV Users not logged in for greater than 90 days"
Get-IAMUsers -ProfileName Dev |select UserName,PasswordLastUsed | Where {$_.UserName -inotmatch 'svc*' -and $_.PasswordLastUsed -lt ((get-date).adddays(-90))} | sort PasswordLastUsed,UserName | Out-File ${filepath}DevUsers.txt
Send-MailMessage -To $mailtoo -From $mailfrom -SmtpServer $smtpserver -Subject $mailsubject -Attachments ${filepath}DevUsers.txt
# *****************************************************************************************************************
# ****** Weekly Run script to check for users > 90 days old in AWS ******
# ****** ******
# ****** Created By Greg W 12/01/2017 ******
# ****** Modified By ******
# ****** Runs from C:\AWS\PS\ folder on ******
# ****** Scheduled Task to run weekly ******
# ****** AWS Logon Variables set using Set-AWSCredentials -AccessKey xyz -SecretKey abc -StoreAs -Whatever ******
# ****** These must be set on a per environment basis on the server where this PS runs. ******
# *****************************************************************************************************************
# Global Variables
$filepath = "C:\AWS\Reports\"
$mailtoo = "recipient@whatever.com"
$mailfrom = "sender@whatever.com"
$smtpserver = "smtpserver"
#DEV Users not logged in > 90 days
#Local Variable for DEV
$mailsubject = "DEV Users not logged in for greater than 90 days"
Get-IAMUsers -ProfileName Dev |select UserName,PasswordLastUsed | Where {$_.UserName -inotmatch 'svc*' -and $_.PasswordLastUsed -lt ((get-date).adddays(-90))} | sort PasswordLastUsed,UserName | Out-File ${filepath}DevUsers.txt
Send-MailMessage -To $mailtoo -From $mailfrom -SmtpServer $smtpserver -Subject $mailsubject -Attachments ${filepath}DevUsers.txt
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Re: Anyone know Powershell? Querying AWS with PS
confirmed - deets on this stuff VERY thin on the ground. will have to write a blog.
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
- psyolent
- Posts: 1595
- Joined: Tue Apr 26, 2011 9:52 pm
- cars: VT Berlina Series 2 Wago
XP Falcon ex Geelong Taxi
SY Ford Territory
PD Hyundai nLine
SE Ford Capri
....too many fucking bikes
Re: Anyone know Powershell? Querying AWS with PS
Landed here
# Global Variables
$filepath = "C:\AWS\Reports\"
$mailtoo = "recipient@whatever.com"
$mailfrom = "sender@whatever.com"
$smtpserver = "smtpserver"
$env_array = "ENV1","ENV2","ENV3"
$env_item = ""
foreach ($env_item in $env_array) {
$mailsubject = $env_item+" Users not logged in for greater than 90 days"
Get-IAMUsers -ProfileName $env_item |select UserName,PasswordLastUsed | Where {$_.UserName -inotmatch 'svc*' -and $_.PasswordLastUsed -lt ((get-date).adddays(-90))} | sort PasswordLastUsed,UserName | Out-File ${filepath}"$env_item Users.txt"
Send-MailMessage -To $mailtoo -From $mailfrom -SmtpServer $smtpserver -Subject $mailsubject -Attachments ${filepath}"$env_item Users.txt"
}
# Global Variables
$filepath = "C:\AWS\Reports\"
$mailtoo = "recipient@whatever.com"
$mailfrom = "sender@whatever.com"
$smtpserver = "smtpserver"
$env_array = "ENV1","ENV2","ENV3"
$env_item = ""
foreach ($env_item in $env_array) {
$mailsubject = $env_item+" Users not logged in for greater than 90 days"
Get-IAMUsers -ProfileName $env_item |select UserName,PasswordLastUsed | Where {$_.UserName -inotmatch 'svc*' -and $_.PasswordLastUsed -lt ((get-date).adddays(-90))} | sort PasswordLastUsed,UserName | Out-File ${filepath}"$env_item Users.txt"
Send-MailMessage -To $mailtoo -From $mailfrom -SmtpServer $smtpserver -Subject $mailsubject -Attachments ${filepath}"$env_item Users.txt"
}
Cheers,
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.
Greg aka Sir Burnie Tanington
VX1 Berlina V6, VT1 Berlina V6 (Track), VN1 S V6, Hilux RN105 GMV8, Ford XP 170.