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 foreachas { | |
Param( | |
[char]$as, | |
[ScriptBlock]$sb | |
) | |
PROCESS { | |
Set-Variable -Name $as -Value $_ | |
Invoke-Command -ScriptBlock $sb |
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
Param( | |
[String]$Path | |
) | |
$pfShortName = ($Path -replace "^\\\\[A-Za-z0-0@\-_. ]*\\All Public Folders\\","").Replace("\","_") | |
$FilePath = Join-Path -Path (Get-Location) -ChildPath "$pfShortName.pst" | |
$outlook = New-Object -ComObject Outlook.Application | |
$namespace = $Outlook.GetNamespace("MAPI") |
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
Get-ChildItem "C:\mydrivers\" -Recurse -Filter "*.inf" | | |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } |
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
$session = New-PSSession -ComputerName MyServer | |
Copy-Item -Path "C:\myfile.txt" -Target "C:\SomeServerFolder" -ToSession $session |
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
$AllUsers = Get-Mailbox -ResultSize unlimited | |
$AllUsers | % { | |
$_.UserPrincipalName | |
$PhotoData = $null | |
$PhotoData = Get-UserPhoto -Identity $_.UserPrincipalNAme -ErrorAction SilentlyContinue | |
if ($PhotoData) { | |
[io.file]::WriteAllBytes("$pwd\$($_.UserPrincipalName).jpg",$Photodata.PictureData) | |
} | |
} |
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
$articleRoot = "articles" | |
$tocFileTypes = @("md") | |
function CreateTocForFolder { | |
Param( | |
[String]$Path | |
) | |
# First, create a toc for child folders |
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
$allDistributionGroups = Get-DistributionGroup -ResultSize unlimited | |
$allGroupMemberships = $allDistributionGroups | ForEach-Object { | |
$thisGroup = $_ | |
Get-DistributionGroupMember -Identity $thisGroup.Identity | | |
Select-Object ` | |
@{Name="GroupIdentity";Expression={$thisGroup.primarySmtpAddress}}, | |
@{Name="MemberAddress";Expression={$_.PrimarySmtpAddress}} | |
} |
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
foreach ($sku in (Get-MsolAccountSku) ) { | |
foreach ($sp in $sku.ServiceStatus) { | |
New-Object -TypeName PSObject -Property @{"AccountSkuId"=$sku.AccountSkuId;"ServicePlan"=$sp.ServicePlan.ServiceName} | |
} | |
} |
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 UpdateImplicitRemotingHandler { | |
$modules = Get-Module tmp_* | |
foreach ($module in $modules) | |
{ | |
[bool]$moduleProcessed = $false | |
[string] $moduleUrl = $module.Description | |
[int] $queryStringIndex = $moduleUrl.IndexOf("?") |
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
$HHUrl = "http://happyhour.virginaustralia.com/sale-on" | |
$page = Invoke-WebRequest -Uri $HHUrl | |
$flightDivs = $page.ParsedHtml.body.getElementsByClassName('card-flight') | |
foreach ($flightDiv in $flightDivs) { | |
New-Object -TypeName PSObject -Property @{ | |
"From" = $flightDiv.getElementsByTagName("h3")[0].innerText.Split("`n")[0].Trim() -replace '\ to', '' |