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
<# | |
This snippet assumes a valid refresh token. To see how to get one of those, check out: | |
https://www.thelazyadministrator.com/2019/07/22/connect-and-navigate-the-microsoft-graph-api-with-powershell/#3_Authentication_and_Authorization_Different_Methods_to_Connect | |
#> | |
$clientId = "1950a258-227b-4e31-a9cf-717495945fc2" # This is the standard client ID for Windows Azure PowerShell | |
$redirectUrl = [System.Uri]"urn:ietf:wg:oauth:2.0:oob" # This is the standard Redirect URI for Windows Azure PowerShell | |
$tenant = "fabrikam.onmicrosoft.com" # TODO - your tenant name goes here | |
$resource = "https://graph.microsoft.com/"; | |
$serviceRootURL = "https://graph.microsoft.com//$tenant" |
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
function ConvertEpoch-ToDateTime | |
{ | |
<# | |
.Synopsis | |
Converts an epoch to a DateTime | |
.DESCRIPTION | |
Needed this for validating JWT tokens using PowerShell. Times were specified as NumericDate per RFC7519 (https://tools.ietf.org/html/rfc7519#section-4.1.4) | |
.EXAMPLE | |
ConvertEpoch-ToDateTime -NumericDate 1565298477 | |
.EXAMPLE |
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
#Install-Module -Name Convert-WindowsImage | |
#Requires module dism : https://docs.microsoft.com/en-us/powershell/module/dism/get-windowsoptionalfeature?view=win10-ps | |
Set-Location $HOME | |
$isoFilePath = 'F:\ISO\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso' | |
$SwitchName = Get-VMSwitch -SwitchType External | Select-Object -expand Name -First 1 | |
$ImageName = 'Windows Server 2016 Datacenter (Desktop Experience)' | |
$ImageVhdFilePath = 'F:\VMs\Virtual Hard Disks\WindowsServer2016-Image.1.vhdx' |
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
### Server management tools preview (next month): https://blogs.technet.microsoft.com/servermanagement/2016/02/09/introducing-server-management-tools/ | |
### View the online docs | |
start https://docs.microsoft.com/en-us/powershell/azuread/v2/azureactivedirectory | |
### Find the module | |
Find-Module AzureAD | Select-Object * | |
<# | |
Version Name Repository Description |
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
#region Pester Training | |
start https://app.pluralsight.com/library/courses/powershell-testing-pester/table-of-contents | |
start https://github.com/pester/Pester/wiki | |
#endregion | |
#region Getting PowerShell (comes with Windows 10) | |
### Find the module in the PowerShell Gallery | |
Find-Module -Name Pester -Repository PSGallery |
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
<# | |
Script showing how to create a KeyVault vault and enable logging | |
(GUIDs redacted) | |
#> | |
New-AzureRmResourceGroup -Name cmartRG0614 -Location westus | |
<# | |
ResourceGroupName : cmartRG0614 | |
Location : westus | |
ProvisioningState : Succeeded |
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
### | |
### Without splatting | |
### | |
Get-Process -Name dns -ComputerName localhost | |
### | |
### With splatting | |
### | |
$myparamas = @{ |
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
<# | |
[Video] A Practical Overview of Desired State Configuration | |
http://channel9.msdn.com/events/TechEd/NorthAmerica/2014/DCIM-B417 | |
[eBook] PowerShell.org DSC Hub | |
http://powershell.org/wp/dsc-hub/ | |
[TechNet] Windows PowerShell Desired State Configuration Overview | |
http://technet.microsoft.com/en-us/library/dn249912.aspx |
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
### Create a sample CSV file | |
@' | |
ColumnA,ColumnB,ColumnC | |
'row1ColA','row1ColB','row1ColC' | |
'row2ColA','row2ColB','row2ColC' | |
'row3ColA','row3ColB','row3ColC' | |
'@ | Out-File -FilePath (Join-Path $env:TEMP testFoo.csv) | |
### Import the sample CSV file | |
Import-Csv -Path (Join-Path $env:TEMP testFoo.csv) |
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
### Load ADAL | |
Add-Type -Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" | |
# Set AAD client ID for the client app | |
$clientId = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" | |
$resourceAppIdURI = "https://TestWebApi01.azurewebsites.net" | |
$authority = "https://login.windows.net/MyAadDirectory.onmicrosoft.com" | |
# Create Authentication Context tied to Azure AD Tenant | |
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority |
NewerOlder