-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...g/How To Copy Files Into A Microsoft Azure Storage Account/Copy-Azure-Storage-Account.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Install-Module AzureRm | ||
|
||
Connect-AzureRmAccount | ||
|
||
# List all Storage Accounts on the connected tenant | ||
Get-AzureRmStorageAccount | Select StorageAccountName | ||
|
||
# Store deisred account in variable | ||
$StorageAccount = Get-AzureRmStorageAccount | where {$_.StorageAccountName -eq 'powershelldepot'} | ||
|
||
# Check for existance of storage blobs | ||
$StorageAccount | Get-AzureStorageContainer | Get-AzureStorageBlob | ||
|
||
# Create, and store, new container | ||
$StorageAccount | New-AzureRmStorageContainer -Name 'demo' | ||
$Container = $StorageAccount | Get-AzureStorageContainer | ||
|
||
# Upload single file | ||
$Container | Set-AzureStorageBlobContent -File 'D:\ImportantData.txt' -Blob 'Important!' | ||
|
||
# Upload multiple files | ||
Get-ChildItem -Path D:\Scripts | foreach { | ||
$Container | Set-AzureStorageBlobContent -File $_.FullName -Blob $_.BaseName | ||
} |
46 changes: 46 additions & 0 deletions
46
...How To Invoke A PowerShell Script Using Amazon Web Services (AWS) Lambda/LambdaPSTest.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Required Modules | ||
Install-Module AWSPowerShell -Scope CurrentUser | ||
Install-Module AWSLambdaPSCore -Scope CurrentUser | ||
|
||
# Import AWS Modules For Demo | ||
Import-Module AWSPowerShell -Force | ||
Import-Module AWSLambdaPSCore -Force | ||
|
||
#region Keys | ||
$accessKey = '' | ||
$secretKey = '' | ||
#endregion | ||
|
||
# Initialize default credential profile | ||
Initialize-AWSDefaultConfiguration -AccessKey $accessKey -SecretKey $secretKey -Region us-east-1 | ||
|
||
# Get current list of Lambda functions | ||
Get-LMFunctionList | ||
|
||
# Get the list of available PowerShell Lambda templates | ||
Get-AWSPowerShellLambdaTemplate | ||
|
||
# Create a starter based on the Basic template | ||
New-AWSPowerShellLambda -ScriptName PSTest -Template Basic | ||
|
||
# Publish the new PowerShell based Lambda function | ||
$publishPSLambdaParams = @{ | ||
Name = 'PSTest' | ||
ScriptPath = '.\PSTest\PSTest.ps1' | ||
Region = 'us-east-1' | ||
IAMRoleArn = 'lambda_basic_execution' | ||
} | ||
Publish-AWSPowerShellLambda @publishPSLambdaParams | ||
|
||
# Get list of Lambda functions including the one we just created | ||
Get-LMFunctionList | ||
|
||
# Invoke the new PowerShell function | ||
$results = Invoke-LMFunction -FunctionName PSTest -InvocationType Event | ||
$results | Select-Object -Property * | ||
|
||
# Get the log events from the invoked function | ||
Get-CWLLogGroup | ||
$logs = Get-CWLFilteredLogEvent -LogGroupName /aws/lambda/PSTest | ||
$logs.Events | ||
|
19 changes: 19 additions & 0 deletions
19
...uting/How To Invoke A PowerShell Script Using Amazon Web Services (AWS) Lambda/PSTest.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# PowerShell script file to be executed as a AWS Lambda function. | ||
# | ||
# When executing in Lambda the following variables will be predefined. | ||
# $LambdaInput - A PSObject that contains the Lambda function input data. | ||
# $LambdaContext - An Amazon.Lambda.Core.ILambdaContext object that contains information about the currently running Lambda environment. | ||
# | ||
# The last item in the PowerShell pipeline will be returned as the result of the Lambda function. | ||
# | ||
# To include PowerShell modules with your Lambda function, like the AWSPowerShell.NetCore module, add a "#Requires" statement | ||
# indicating the module and version. | ||
|
||
#Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.335.0'} | ||
|
||
# Uncomment to send the input event to CloudWatch Logs | ||
# Write-Host (ConvertTo-Json -InputObject $LambdaInput -Compress -Depth 5) | ||
|
||
Write-Host "Hell World" | ||
|
||
$LambdaInput.key2 |
14 changes: 14 additions & 0 deletions
14
Linux/How To Install PowerShell Core On Debian (Ubuntu)/PSCore-Ubuntu.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Download the Microsoft repository GPG keys | ||
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb | ||
|
||
# Register the Microsoft repository GPG keys | ||
sudo dpkg -i packages-microsoft-prod.deb | ||
|
||
# Update the list of products | ||
sudo apt-get update | ||
|
||
# Install PowerShell | ||
sudo apt-get install -y powershell | ||
|
||
# Start PowerShell | ||
pwsh |
8 changes: 8 additions & 0 deletions
8
...ing/How To Find All Listening Ports On A Windows Computer With PowerShell/PortTesting.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Get-NetTCPConnection -State Listen | | ||
Select-Object -Property LocalAddress, | ||
LocalPort, | ||
RemoteAddress, | ||
RemotePort, | ||
@{name='Process';expression={(Get-Process -Id $_.OwningProcess).Name}}, | ||
CreationTime | | ||
Format-Table -AutoSize |