Skip to content

Instantly share code, notes, and snippets.

View DexterPOSH's full-sized avatar
🌱
Learning && Growing

Deepak Singh Dhami DexterPOSH

🌱
Learning && Growing
View GitHub Profile
@DexterPOSH
DexterPOSH / use_account_SAS.ps1
Created November 5, 2017 19:04
Code sample showing how to use Account SAS token to update the service properties on the Blob service.
# variables
$StorageAccountName = 'azprepstore'
$storSAS = '<SAS token value generated in previous step>'
# Create the new storage context with the Account SAS token generated above.
$ClientContext = New-AzureStorageContext -SasToken $storSAS -StorageAccountName $StorageAccountName
# try to fetch the Blobs using the above context and it will fail
# since the SAS token only grants access to the Service level APIs
@DexterPOSH
DexterPOSH / create_an_account_SAS.ps1
Created November 5, 2017 18:58
Code sample that shows how to create an account SAS token.
# variables
$resourceGroupName = 'azureprep'
$StorageAccountName = 'azprepstore'
# Login to ASM & ARM modules, the cmdlets for creating SAS tokens are not yet available under ARM modules
Add-AzureAccount
Login-AzureRmAccount
# Get all azure subscription which are attached with your account
Get-AzureSubscription | Sort-Object -Property SubscriptionName | Select-Object -Property SubscriptionName
@DexterPOSH
DexterPOSH / Blog-node-connectivity-helper.psm1
Created September 28, 2017 10:50
Function Test-NetConnectionWithSourceAddress definition.
Function Test-NetConnectionWithSourceAddress
{
[CmdletBinding()]
[Alias('PortTestWithSource')]
[OutputType([Boolean])]
Param
(
# Specify the remote destination IPAddress.
[Parameter(Mandatory=$False,
ValueFromPipelineByPropertyName=$true,
@{
AllNodes = @(
@{
# common node information hashtable
NodeName = '*'; # do not edit
SETTeamName = 'S2DSwitch'; # <Edit> name of the SET team
DomainDCs = @('testad.Test.lab') # <edit> the DC names (can be a single value)
DNSServers = @('testad.Test.lab') # <edit> the DNS names (can be a single value)
Domain = 'test.lab' # <edit> the domain name
ClusterName = 'r740-mid-s2d-cluster' # <edit> the cluster name,
@DexterPOSH
DexterPOSH / PSdeploy.Argumentcompleter.ps1
Created November 28, 2016 15:29
Try to create tab completion for the PSDeploy DSL.
Function PSDeployCompletion
{
param( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$CommandTree = Get-CompletionPrivateData -Key PSDeployCompletionCommandTree
if ($null -eq $CommandTree) {
$CommandTree = & {
New-CommandTree -Completion FromSource -ToolTip 'Source' -Argument
New-CommandTree -Completion To -ToolTip 'Destination' -Argument
@DexterPOSH
DexterPOSH / PSdeploy.Argumentcompleter.ps1
Created November 28, 2016 15:28
Try to create tab completion for the PSDeploy DSL.
Function PSDeployCompletion
{
param( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$CommandTree = Get-CompletionPrivateData -Key PSDeployCompletionCommandTree
if ($null -eq $CommandTree) {
$CommandTree = & {
New-CommandTree -Completion FromSource -ToolTip 'Source' -Argument
New-CommandTree -Completion To -ToolTip 'Destination' -Argument
@DexterPOSH
DexterPOSH / Test-PortReachableUsingSourceIP.ps1
Created March 14, 2016 06:15
Test-PortReachableUsingSourceIP
Function Test-PortReachableUsingSourceIP
{
[CmdletBinding()]
[Alias()]
[OutputType([int])]
Param
(
# Specify the remote destination IPAddress.
[Parameter(Mandatory=$False,
ValueFromPipelineByPropertyName=$true,
@DexterPOSH
DexterPOSH / New-TestVM.ps1
Last active August 29, 2015 14:27
Azure Automation runbook to deploy a Server 2016 TP3 VM on Azure.
workflow New-TestVM
{
param(
# Sepcify the Azure Subscription Name
[parameter(Mandatory)]
[String]
$AzureSubscriptionName,
# Sepcify the Azure Storage Account Name to be used to store VM VHDs.
[parameter(Mandatory)]
@DexterPOSH
DexterPOSH / append_configurecloudservice.ps1
Created July 10, 2015 08:20
sample gist to append to the configurecloudservice.ps1 (or you can add a new ps1) to access custom settings defined for the Cloud Service
TRY {
# search for the Dll
Write-Verbose -Message "Creating credential object"
$Splathashtable = @{
'Path' = "$env:windir\Microsoft.NET\assembly\";
'Filter' = 'Microsoft.WindowsAzure.ServiceRuntime.dll';
'Include' = '*.dll'
}
$dllfile = Get-ChildItem @Splathashtable -Recurse | Select-Object -Last 1 # selecting only one object, in case of multiple results
@DexterPOSH
DexterPOSH / ps.cmd
Created July 10, 2015 08:15
default ps.cmd which gets added to the VS Project
@echo off
cd /D %~dp0
if not exist "%DiagnosticStore%\LogFiles" mkdir "%DiagnosticStore%\LogFiles"
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File %* >> "%DiagnosticStore%\LogFiles\%~n1.txt" 2>> "%DiagnosticStore%\LogFiles\%~n1.err.txt"