Skip to content

Commit

Permalink
goodness
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram committed Oct 22, 2018
1 parent ab8d033 commit 9fcb1ef
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
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
}
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

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
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
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

0 comments on commit 9fcb1ef

Please sign in to comment.