Skip to content

Instantly share code, notes, and snippets.

View marckean's full-sized avatar

Marc Kean marckean

View GitHub Profile
#To connect
$ServerName = "ServerName.cloudapp.net"
$port = '5986'
#region creds
$adminname = 'user.name'
$adminpassword = 'paasword'
#endregion
$password = ConvertTo-SecureString $adminpassword -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential (".\$adminname", $password)
### Enter session
### Log into Azure ARM
Login-AzureRmAccount
### Choose subscription 'new' Azure
$subscription = (Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru).SubscriptionName
Select-AzureRmSubscription -SubscriptionName $subscription
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Network\AzureRM.Network.psd1"
##########################################################################
### Log into Azure ARM
Login-AzureRmAccount
### Choose subscription 'new' Azure
$subscription = (Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru).SubscriptionName
Select-AzureRmSubscription -SubscriptionName $subscription
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Network\AzureRM.Network.psd1"
##########################################################################
#Log into both old and new Azure
Login-AzureRmAccount
#Choose subscription 'new' Azure
$subscription = (Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru).SubscriptionName
Select-AzureRmSubscription -SubscriptionName $subscription
##########################################################################
############################# NSG DMZ #############################
##########################################################################
#Log into both old and new Azure
Login-AzureRmAccount
#Choose subscription 'new' Azure
$subscription = (Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru).SubscriptionName
Select-AzureRmSubscription -SubscriptionName $subscription
$RGName = "Show-DMZ_VM"
$location = "australiaeast"
#Log into both old and new Azure
Login-AzureRmAccount
#Choose subscription 'new' Azure
$subscription = (Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru).SubscriptionName
Select-AzureRmSubscription -SubscriptionName $subscription
$RGName = "Show-Internal_VMs"
$location = "australiaeast"
$RadioFormat = 'Kiis'
$WritetoTableStorage = 'Yes'
$TableName = "JustPlayedKiis"
#Define the storage account and context.
$StorageAccountName = "StorageAccountName"
$StorageAccountKey = "StorageAccountKey"
$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey
#region Clear the cache (variables)
#region Install Modules
# Run as Administrator
Find-Module AzureRM.OperationalInsights | Install-Module
# Or run as the current user
Install-Module AzureRM.OperationalInsights -Scope CurrentUser
#endregion
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ExtendedUIHoverTime' -PropertyType DWord -Value 2328 -Force
#region Connect to Remote PowerShell WinRM HTTPS port 5986 with untrusted certificate - single connection
### Variables
$ServerName = "ServerName / or / IP Address"
$adminname = 'UserName'
$adminpassword = 'Password'
$password = ConvertTo-SecureString $adminpassword -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential (".\$adminname", $password)
### Enter session
$SessionOptions = New-PSSessionOption –SkipCACheck –SkipCNCheck –SkipRevocationCheck
Enter-PSSession -ComputerName $ServerName -Port 5986 -UseSSL -Credential $cred -SessionOption $SessionOptions