All sizes in MB, change /1024/1024 to /1024/1024/1024 for GB.
Without system databases
select
datname as database,
(pg_database_size(datname)/1024/1024) as size| import botocore.waiter | |
| import botocore.session | |
| session = botocore.session.get_session() | |
| client = session.create_client('ec2') | |
| VOLUME_ID = ... # e.g. 'vol-049df61146c4d7901' | |
| INSTANCE_ID = ... # e.g. 'i-1234567890abcdef0' | |
| DEVICE = ... # e.g. '/dev/xvdba' |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| # path to the files with a wildcard at the end | |
| $sourcePath = "C:\Repos\excelpassword\*" | |
| # place to save the files | |
| $destPath = "C:\Repos\excelpassword" | |
| # gets a list of all the files but only includes files with the .xlsx extension | |
| $items = Get-ChildItem -Path $sourcePath -Include *.xlsx | |
| # password for the file(s) | |
| $password = 'T&4gh!$Tnw' | |
| # Creates the excel object | |
| $excel = New-Object -comobject Excel.Application |
| Get-AWSSAMLAssertion -rolescope All | |
| foreach ($stsrole in $global:stsroles) | |
| { | |
| Set-AWSCredentials -AccessKey $stsrole.credentials.AccessKeyId -SecretKey $stsrole.credentials.SecretAccessKey -SessionToken $stsrole.credentials.SessionToken | |
| $checks = Get-ASATrustedAdvisorChecks -Language en | |
| $i = 0 | |
| $account = Get-IAMAccountAlias | |
| if ($stsrole.credentials.Expiration -gt (Get-Date)) | |
| { |
| # Installs the AzureRM PowerShell module from the PSGallery | |
| Install-Module AzureRM -force | |
| # Logs you in to Azure | |
| Login-AzureRmAccount | |
| # Gets your Azure subscription then selects it which essentially logs you in to it. Needs to be done if your account has access | |
| # to multiple subscription | |
| Get-AzureRmSubscription -SubscriptionName "enter your subscription name" | Select-AzureRmSubscription | |
| # Gets a list of all the Azure VM's in your subscription | |
| $vms = Get-AzureRmVM | |
| # Initializes a empty variable for $details to give it the ability to add more than one item easily |
| $blah = @("<script>`n", 'cfn-init.exe -v -s ', ' -r WindowsServer2012R2 ', ` | |
| ' --region ', "`n", '</script>') |
| Function Get-LoggedOnUsers { | |
| <# | |
| .Synopsis | |
| Queries a computer to check for interactive sessions | |
| .DESCRIPTION | |
| This script takes the output from the quser program and parses this to PowerShell objects | |
| .NOTES | |
| Name: Get-LoggedOnUser |