Requires
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| import urllib2 | |
| import json | |
| def lambda_handler(event, context): | |
| url = 'https://rightgif.com/search/web' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get input and output params (as named in our function.json) | |
| $result = $Env:res | |
| $requestPath = $env:req | |
| $executionPath = Split-Path -parent $PSCommandPath | |
| $tempPath = Split-Path -parent $env:req | |
| # Read the input from file and parse it to an object | |
| [Console]::WriteLine("Reading input from $env:req") | |
| $requestObj = get-content $requestPath | out-string | convertfrom-json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <powershell> | |
| Enable-PSRemoting -force | |
| Set-Item WSMan:\localhost\MaxTimeoutms 1800000 | |
| Set-Item WSMan:\localhost\Service\AllowRemoteAccess $true | |
| Set-Item WSMan:\localhost\Service\Auth\Basic $true | |
| Set-item WSMan:\localhost\Service\AllowUnencrypted $true | |
| $computername = $env:computername # place computername here for remote access | |
| $username = 'AdminAccount1' | |
| $password = 'topSecret@99' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Stolen from http://ctrlf5.net/?p=263 and http://www.dailycoding.com/posts/convert_image_to_base64_string_and_base64_string_to_image.aspx | |
| function ConvertFrom-StringToMemoryStream{ | |
| param( | |
| [parameter(Mandatory)] | |
| [string]$InputString | |
| ) | |
| $stream = New-Object System.IO.MemoryStream; | |
| $writer = New-Object System.IO.StreamWriter($stream); | |
| $writer.Write($InputString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Dimension1 = New-Object Amazon.CloudWatch.Model.Dimension | |
| $dimension1.set_Name("Currency") | |
| $dimension1.set_Value("USD") | |
| # Has to be us-east-1 irrespective of what regions you use | |
| $result = Get-CWMetricStatistics -MetricName EstimatedCharges -region us-east-1 -Namespace "AWS/Billing" -StartTime (Get-Date).AddDays(-14) -EndTime (get-date) -Period (60*60*24) -Statistics 'Maximum' -Dimensions @($Dimension1, $Dimension2) | |
| $result.Datapoints | select timestamp,maximum | sort timestamp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-S3FolderLastModified { | |
| param( | |
| [parameter(mandatory=$true)] | |
| [string]$folder, | |
| [parameter(mandatory=$true)] | |
| [string]$bucket, | |
| [parameter(mandatory=$true)] | |
| [string]$region | |
| ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gc "iislogfile.log" | %{ | |
| $row = $_.split(' ') | |
| New-Object psobject -Property @{ | |
| # date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken OriginalIPAddress | |
| DateCreated = Get-Date ($row[0] + ' ' + $row[1]) | |
| "s-ip" = $row[2] | |
| "cs-method" = $row[3] | |
| "cs-uri-stem" = $row[4] | |
| "cs-uri-query" = $row[5] | |
| "s-port" = $row[6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreach($cluster in Get-Cluster){ | |
| # Get host memory free | |
| $vmHostObj = $cluster | Get-VMHost | |
| $totalVMHostMemory = [int]$($vmHostObj | measure-object -property MemoryTotalGB -sum).sum; | |
| $totalVMHostMemoryFree = $($vmHostObj | %{$_.MemoryTotalGB - $_.MemoryUsageGB} | measure-object -sum).sum; | |
| $highestHostMemoryTotal = $($vmHostObj | sort-object -property MemoryTotalGB | select -last 1).MemoryTotalGB; | |
| $totalVMHostCPU = [int]$($vmHostObj | measure-object -property CPUTotalMhz -sum).sum; | |
| $totalVMHostCPUFree = $($vmHostObj | %{$_.CPUTotalMhz - $_.CPUUsageMhz} | measure-object -sum).sum; | |
| $highestHostCPUTotal = $($vmHostObj | sort-object -property CPUTotalMhz | select -last 1).CPUTotalMhz; |
Replace yourdomain with your service now URL. User must have the rest_service role.