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
#Requires -Version 5.0.9814.0 | |
if(!($PSVersionTable.PSVersion.Major -ge 5 -and $PSVersionTable.PSVersion.Build -ge 9814)) { | |
"Sorry you need PSVersion 5.0.9814.0 or newer" | |
$psversiontable | |
return | |
} | |
Add-Type -AssemblyName presentationframework |
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
<# | |
List taken from SO answer: | |
http://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value | |
#> | |
$ExCellStyles = @{ | |
0 = 'General' | |
1 = '0' | |
2 = '0.00' | |
3 = '#,##0' |
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
<# | |
.Synopsis | |
Facilitates the loading of specific properties of a Microsoft.SharePoint.Client.ClientObject object or Microsoft.SharePoint.Client.ClientObjectCollection object. | |
.DESCRIPTION | |
Replicates what you would do with a lambda expression in C#. | |
For example, "ctx.Load(list, l => list.Title, l => list.Id)" becomes | |
"Load-CSOMProperties -object $list -propertyNames @('Title', 'Id')". | |
.EXAMPLE | |
Load-CSOMProperties -parentObject $web -collectionObject $web.Fields -propertyNames @("InternalName", "Id") -parentPropertyName "Fields" -executeQuery | |
$web.Fields | select InternalName, Id |
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 Get-WSManTrust { | |
(Get-Item -Path WSMan:\localhost\Client\TrustedHosts | % Value).split(',') | |
} | |
function New-WSManTrust { | |
param( | |
[string]$hostname | |
) | |
Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $hostname -Concatenate -Force | |
} |
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
$source = "C:\LabResources\xTimeZone" | |
$destination = "C:\temp" | |
$Version = (Get-ChildItem -Path $source -Depth 1).Name | |
$ResoureName = (Get-ChildItem -Path $source -Depth 1).Parent.Name | |
$ModuleName = $ResoureName+'_'+$Version | |
New-Item -Path ($destination+'\'+$ModuleName) -ItemType Directory |
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
<# | |
.SYNOPSIS | |
The synopsis goes here. This can be one line, or many. | |
This version of the template has inbuilt functions to capture credentials and store it securely for reuse | |
Avoids the need to have plaintext passwords in the script | |
.DESCRIPTION | |
The description is usually a longer, more detailed explanation of what the script or function does. | |
Take as many lines as you need. |
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
using namespace System.Numerics | |
class Mandelbrot : System.Collections.IEnumerator { | |
# From the constructor? | |
# Sadly, PowerShell doesn't support optional parameters | |
[double]$HorizontalViewOffset = -0.5 | |
[double]$VerticalViewOffset = 0 | |
$Columns = 120 | |
$Rows = 28 | |
$ZoomViewDistance = 6.75 |
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 Out-JSONView { | |
[cmdletbinding()] | |
Param ( | |
[parameter(ValueFromPipeline)] | |
[psobject]$InbutObject, | |
[int]$Depth = 2 |
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 ConvertFrom-SID { | |
param ( | |
[Parameter(Position = 0, Mandatory = $True)] | |
[String] | |
[ValidateNotNullOrEmpty()] | |
$SID | |
) | |
$AccountSIDInstance = Get-CimInstance -ClassName Win32_AccountSID -Filter "Setting = 'Win32_SID.SID=`"$SID`"'" |
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 Get-DirectoryContent { | |
<# | |
.SYNOPSIS | |
Function to get directory content | |
.EXAMPLE | |
Get-DirectoryContent -Path "C:\" -HeaderName "poshserver.net" -RequestURL "http://poshserver.net" -SubfolderName "/" | |
OlderNewer