This file contains hidden or 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 Assemblies | |
| $adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" | |
| $adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll" | |
| [System.Reflection.Assembly]::LoadFrom($adal) | |
| [System.Reflection.Assembly]::LoadFrom($adalforms) | |
| #> | |
| function Get-AzureObject { | |
| [CmdletBinding()] |
This file contains hidden or 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
| PS X:\> Get-Command -Name "*log*" | where source -like "Azure*" | |
| CommandType Name Version Source | |
| ----------- ---- ------- ------ | |
| Alias Get-WAPackWebsiteLog 1.2.3 Azure | |
| Alias Login-AzureRmAccount 1.0.5 AzureRM.Profile | |
| Alias Save-WAPackWebsiteLog 1.2.3 Azure | |
| Cmdlet Export-ACSLog 0.9.3 AzureRM.AzureStackStorage | |
| Cmdlet Get-AzureRmDataLakeAnalyticsCatalogItem 1.0.5 AzureRM.DataLakeAnalytics | |
| Cmdlet Get-AzureRmLog 1.0.5 AzureRM.Insights |
This file contains hidden or 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
| $paths = | |
| "C:\SyncLog\logFile1.log", | |
| "C:\SyncLog\logFile2.log", | |
| "C:\SyncLog\logFile3.log", | |
| "C:\SyncLog\logFile4.log", | |
| "C:\SyncLog\logFile5.log" | |
| $reportsPath = "C:\SyncLog\Reports" | |
| foreach ($p in $paths) { |
This file contains hidden or 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 Find-ASTItem { | |
| param( | |
| [string[]]$FullName, | |
| [ScriptBlock]$FindAll | |
| ) | |
| Process { | |
| $Ast = [System.Management.Automation.Language.Parser]::ParseFile( (Resolve-Path $FullName) , [ref]$null, [ref]$null) | |
| foreach($item in $ast.FindAll($FindAll, $true)) { |
This file contains hidden or 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
| $f = gc "C:\Temp\pfirewall_public.log" | |
| $regex = '^(?<datetime>\d{4,4}-\d{2,2}-\d{2,2}\s\d{2}:\d{2}:\d{2})\s(?<action>\w+)\s(?<protocol>\w+)\s(?<srcip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<dstip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<srcport>\d{1,5})\s(?<dstport>\d{1,5})\s(?<size>\d+|-)\s(?<tcpflags>\d+|-)\s(?<tcpsyn>\d+|-)\s(?<tcpack>\d+|-)\s(?<tcpwin>\d+|-)\s(?<icmptype>\d+|-)\s(?<icmpcode>\d+|-)\s(?<info>\d+|-)\s(?<path>.+)$' | |
| $log = | |
| $f | % { | |
| $_ -match $regex | Out-Null | |
| if ($Matches) { | |
| [PSCustomObject]@{ | |
| action = $Matches.action |
This file contains hidden or 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
| using assembly "C:\Users\<username>\AppData\Local\PackageManagement\NuGet\Packages\Microsoft.Azure.DocumentDB.1.19.1\lib\net45\Microsoft.Azure.Documents.Client.dll" | |
| $client = [Microsoft.Azure.Documents.Client.DocumentClient]::new([Uri]("https://localhost:8081"),"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==") | |
| $db = $client.CreateDatabaseIfNotExistsAsync([Microsoft.Azure.Documents.Database]@{ID="azureinventory"}) | |
| $docCollection = $client.CreateDocumentCollectionIfNotExistsAsync([Microsoft.Azure.Documents.Client.UriFactory]::CreateDatabaseUri("azureinventory"), | |
| [Microsoft.Azure.Documents.DocumentCollection]@{id="inventory"}, | |
| [Microsoft.Azure.Documents.Client.RequestOptions]@{OfferThroughput = 1000}) | |
| $docCollectionURI = [Microsoft.Azure.Documents.Client.UriFactory]::CreateCollectionUri("azureinventory", "inventory") |
This file contains hidden or 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
| using assembly "C:\Users\<user>\AppData\Local\PackageManagement\NuGet\Packages\Microsoft.Azure.DocumentDB.1.19.1\lib\net45\Microsoft.Azure.Documents.Client.dll" | |
| $client = [Microsoft.Azure.Documents.Client.DocumentClient]::new([Uri]("https://localhost:8081"),"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==") | |
| $db = $client.CreateDatabaseIfNotExistsAsync([Microsoft.Azure.Documents.Database]@{ID="azureinventory"}) | |
| $docCollection = $client.CreateDocumentCollectionIfNotExistsAsync([Microsoft.Azure.Documents.Client.UriFactory]::CreateDatabaseUri("azureinventory"), | |
| [Microsoft.Azure.Documents.DocumentCollection]@{id="inventory"}, | |
| [Microsoft.Azure.Documents.Client.RequestOptions]@{OfferThroughput = 1000}) | |
| $docCollectionURI = [Microsoft.Azure.Documents.Client.UriFactory]::CreateCollectionUri("azureinventory", "inventory") |
This file contains hidden or 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
| #file and regular expression | |
| $f = gc "C:\Temp\pfirewall_public.log" | |
| $regex = '^(?<datetime>\d{4,4}-\d{2,2}-\d{2,2}\s\d{2}:\d{2}:\d{2})\s(?<action>\w+)\s(?<protocol>\w+)\s(?<srcip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<dstip>\b(?:\d{1,3}\.){3}\d{1,3}\b)\s(?<srcport>\d{1,5})\s(?<dstport>\d{1,5})\s(?<size>\d+|-)\s(?<tcpflags>\d+|-)\s(?<tcpsyn>\d+|-)\s(?<tcpack>\d+|-)\s(?<tcpwin>\d+|-)\s(?<icmptype>\d+|-)\s(?<icmpcode>\d+|-)\s(?<info>\d+|-)\s(?<path>.+)$' | |
| #parsing | |
| $log = | |
| $f | % { | |
| $_ -match $regex | Out-Null | |
| if ($Matches) { | |
| [PSCustomObject]@{ |
This file contains hidden or 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 Find-ASTItem { | |
| param( | |
| [string[]]$FullName, | |
| [ScriptBlock]$FindAll | |
| ) | |
| Process { | |
| $Ast = [System.Management.Automation.Language.Parser]::ParseFile( (Resolve-Path $FullName) , [ref]$null, [ref]$null) | |
| foreach($item in $ast.FindAll($FindAll, $true)) { |
This file contains hidden or 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 Test-Password { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(ValueFromPipeline=$true)] | |
| [string]$Password | |
| ) | |
| begin { | |
| [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
| } |
OlderNewer