Saturday, April 4, 2020

Videos

Basic PowerShell Videos

Shane Young

PowerShell 101

https://www.youtube.com/playlist?list=PLCGGtLsUjhm2k22nFHHdupAK0hSNZVfXi
Part 1 - Basics
https://www.youtube.com/watch?v=IHrGresKu2w
Part 2
https://www.youtube.com/watch?v=f9xPJXslVWE
Copy, Move, Delete files with PowerShell
https://www.youtube.com/watch?v=QuLxJRT3Mhg

Advanced PowerShell Videos

Don Jones

Month of Lunches

Tooling Making

Advanced Series
Live Interactive Session - A great tool building video series
Note this was a recorded live session (Warning: Some Adult Language)

Part 1
https://www.youtube.com/watch?v=KprrLkjPq_c
Part 2
https://www.youtube.com/watch?v=U849a17G7Ro
Part 3
https://www.youtube.com/watch?v=GXdmjCPYYNM


Friday, July 26, 2019

Best PowerShell Functions & Scripts Ever!

So you want to jazz up your scripts … check out these great additions

Basic Beep

#beep

[console]::beep(440,500)

#scale

$scale=@{
MidC=261.6
CSharp=277.2
D=293.7
DSharp=311.1
E=329.6
F=349.2
FSharp=370.0
G=392.0
GSharp=415.3
A=440.0
ASharp=466.2
B=493.9
C=523.2
}

#play a chromatic scale
write-host “First octave” -ForegroundColor Cyan
$scale.values | sort | foreach {[console]::beep($_,125)}

Basic Music

# Star Wars

Function Play-StarWars {
      [console]::beep(440,500)
      [console]::beep(440,500)
      [console]::beep(440,500)
      [console]::beep(349,350)
      [console]::beep(523,150)
      [console]::beep(440,500)
      [console]::beep(349,350)
      [console]::beep(523,150)
      [console]::beep(440,1000)
      [console]::beep(659,500)
      [console]::beep(659,500)
      [console]::beep(659,500)
      [console]::beep(698,350)
      [console]::beep(523,150)
      [console]::beep(415,500)
      [console]::beep(349,350)
      [console]::beep(523,150)
      [console]::beep(440,1000)
}

Play-StarWars

#imperial march

Function Play-ImperialMarch{

[console]::beep(440,500)
[console]::beep(440,500)
[console]::beep(440,500)
[console]::beep(349,350)
[console]::beep(523,150)

[console]::beep(440,500)
[console]::beep(349,350)
[console]::beep(523,150)
[console]::beep(440,1000)

[console]::beep(659,500)
[console]::beep(659,500)
[console]::beep(659,500)
[console]::beep(698,350)
[console]::beep(523,150)

[console]::beep(415,500)
[console]::beep(349,350)
[console]::beep(523,150)
[console]::beep(440,1000)

[console]::beep(880,500)
[console]::beep(440,350)
[console]::beep(440,150)
[console]::beep(880,500)
[console]::beep(830,250)
[console]::beep(784,250)

[console]::beep(740,125)
[console]::beep(698,125)
[console]::beep(740,250)

[console]::beep(455,250)
[console]::beep(622,500)
[console]::beep(587,250)
[console]::beep(554,250)

[console]::beep(523,125)
[console]::beep(466,125)
[console]::beep(523,250)

[console]::beep(349,125)
[console]::beep(415,500)
[console]::beep(349,375)
[console]::beep(440,125)

[console]::beep(523,500)
[console]::beep(440,375)
[console]::beep(523,125)
[console]::beep(659,1000)

[console]::beep(880,500)
[console]::beep(440,350)
[console]::beep(440,150)
[console]::beep(880,500)
[console]::beep(830,250)
[console]::beep(784,250)

[console]::beep(740,125)
[console]::beep(698,125)
[console]::beep(740,250)

[console]::beep(455,250)
[console]::beep(622,500)
[console]::beep(587,250)
[console]::beep(554,250)

[console]::beep(523,125)
[console]::beep(466,125)
[console]::beep(523,250)

[console]::beep(349,250)
[console]::beep(415,500)
[console]::beep(349,375)
[console]::beep(523,125)

[console]::beep(440,500)
[console]::beep(349,375)
[console]::beep(261,125)
[console]::beep(440,1000)

}

Play-ImperialMarch

# Mission Impossible

Function Play-MissionImpossible{

[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(932,150)
Start-Sleep -m 150
[console]::beep(1047,150)
Start-Sleep -m 150
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(699,150)
Start-Sleep -m 150
[console]::beep(740,150)
Start-Sleep -m 150
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(932,150)
Start-Sleep -m 150
[console]::beep(1047,150)
Start-Sleep -m 150
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(784,150)
Start-Sleep -m 300
[console]::beep(699,150)
Start-Sleep -m 150
[console]::beep(740,150)
Start-Sleep -m 150
[console]::beep(932,150)
[console]::beep(784,150)
[console]::beep(587,1200)
Start-Sleep -m 75
[console]::beep(932,150)
[console]::beep(784,150)
[console]::beep(554,1200)
Start-Sleep -m 75
[console]::beep(932,150)
[console]::beep(784,150)
[console]::beep(523,1200)
Start-Sleep -m 150
[console]::beep(466,150)
[console]::beep(523,150)

}

Play-MissionImpossible

# Mario

Function Play-Mario{

$i = 1

do {Write-Host $i; $i++

[console]::beep(659,250) ##E

[console]::beep(659,250) ##E

[console]::beep(659,300) ##E

[console]::beep(523,250) ##C

[console]::beep(659,250) ##E

[console]::beep(784,300) ##G

[console]::beep(392,300) ##g

[console]::beep(523,275) ## C

[console]::beep(392,275) ##g

[console]::beep(330,275) ##e

[console]::beep(440,250) ##a

[console]::beep(494,250) ##b

[console]::beep(466,275) ##a#

[console]::beep(440,275) ##a

[console]::beep(392,275) ##g

[console]::beep(659,250) ##E

[console]::beep(784,250) ## G

[console]::beep(880,275) ## A

[console]::beep(698,275) ## F

[console]::beep(784,225) ## G

[console]::beep(659,250) ## E

[console]::beep(523,250) ## C

[console]::beep(587,225) ## D

[console]::beep(494,225) ## B

}

until ($i -gt 1)

}

Play-Mario

Advanced Music

# Mario Long Version

function Play-Mario-Long {

function b($a,$b){
     [console]::beep($a,$b)
}
function s($a){
     sleep -m $a
}
write-host "Super Mario!"
b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 150;
b 660 80;
s 550;

b 870 80;
s 325;
b 760 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;
}

Play-Mario-Long

# Christmas Music Jingle Bells

Function Play-JingleBells{

$Notes = New-Object -TypeName psobject -Property @{
     REST    = 0
     GbelowC = 196
     A       = 220
     Asharp  = 233
     B       = 247
     C       = 262
     Csharp  = 277
     D       = 294
     Dsharp  = 311
     E       = 330
     F       = 349
     Fsharp  = 370
     G       = 392
     Gsharp  = 415
     AA      = 440
     AAsharp = 466
     BB      = 493
     CC      = 523
     CCsharp = 554
     DD      = 587
     DDsharp = 622
     EE      = 659
     FF      = 698
     FFsharp = 740
     GG      = 784
     GGsharp = 830
     }
 
$Duration = New-Object -TypeName psobject -Property @{
     WHOLE     = 1600
     HALF      = 800
     QUARTER   = 400
     EIGHTH    = 200
     SIXTEENTH = 100
     }
 
 
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.C, $Duration.HALF   )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.D, $Duration.HALF   )
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.D, $Duration.EIGHTH )
[console]::beep($Notes.E, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
 
[console]::beep($Notes.E, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.E, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.C, $Duration.HALF   )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.D, $Duration.HALF   )
Start-Sleep -m $Duration.QUARTER
[console]::beep($Notes.D, $Duration.EIGHTH )
 
 
[console]::beep($Notes.E, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.EIGHTH)
[console]::beep($Notes.DD, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.HALF)
[console]::beep($Notes.CC, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
 
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.EIGHTH)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.HALF)
[console]::beep($Notes.CC, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
 
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.HALF)
}

Play-JingleBells

# Turkish Anthem

powershell.exe -enc JABhAD0AMgA5ADMALAA0ADQAMAAsADQANAAwACwANAA0ADAALAA0ADQAMAAsADQANAAwACwANAA0ADAALAA0ADYANgAsADQANAAwACwAMwA5ADIALAA0ADYANgAsADQANAAwACwAMgA5ADMALAA0ADQAMAAsADQANAAwACwANAA0ADAALAA0ADQAMAAsADQANAAwACwANAA0ADAALAA0ADYANgAsADQANAAwACwAMwA5ADIALAA0ADYANgAsADQANAAwACwANAA0ADAALAA1ADgANwAsADUAMgAzACwANAA2ADYALAA0ADQAMAAsADMAOQAyACwANAA0ADAALAAzADkAMgAsADMANAA5ACwAMwAyADkALAAzADQAOQAsADQANAAwACwAMgA5ADMALAA0ADQAMAAsADMAOQAyACwAMwA0ADkALAAzADIAOQAsADIAOQAzACwAMwA0ADkALAAzADIAOQAsADIAOQAzACwAMgA2ADEALAAyADkAMwA7ACQAYgA9ADgAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA5ADAAMAAsADgAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA5ADAAMAAsADgAMAAwACwAOAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwAOAAwADAALAA5ADAAMAAsADgAMAAwACwAOAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwANAAwADAALAA0ADAAMAAsADQAMAAwACwAOAAwADAAOwAkAGMAPQBAACgAMAAuAC4ANAA2ACkAOwAkAGMALgBGAG8AcgBFAGEAYwBoAHsAWwBDAG8AbgBzAG8AbABlAF0AOgA6AEIAZQBlAHAAKAAkAGEAWwAkAF8AXQAsACQAYgBbACQAXwBdACkAfQA=

References

https://medium.com/@bmerenler/powershell-intro-with-simple-beep-music-71535383e017

https://social.technet.microsoft.com/wiki/contents/articles/20989.music-from-the-command-line-performed-by-powershell.aspx

Thursday, July 25, 2019

Work Day PowerShell

$URL = "https://lms.nhcms.net/" #Replace this link with your calendar page (they hardcode your id in the URL)
$Username = "Username" #Replace Username with your LMS Username
$Password = "Password" #Replace Password with your LMS Password

$IE = New-Object -ComObject internetexplorer.application
$IE.visible = $true
$IE.navigate($URL)

While ($IE.Busy -eq $true) {
     Start-Sleep -Seconds 1
} #End while (this is needed to pause internet explorer so it can add the data to the fields.

$IE.document.IHTMLDocument3_getElementByID("UserName").Value = $Username
$IE.Document.IHTMLDocument3_getElementByID("Password").Value = $Password
($IE.Document.IHTMLDocument3_getElementsByTagName("Input") | Where-Object {$_.type -eq "submit" -and $_.value -eq "Login"} | Select-Object -First 1).Click()  #Needed because the LMS does not have ID or Name fields for their buttons


The above script will auto login to a webpage, in this case our LMS system. This uses IE Com object for logging into a website. It only works with IE (no chrome or edge). I use this in a Powershell module called Start-Workday which loads my admin tools I use for the day.

I also created a shortcut for Start-Workday and renamed the script to Work day. This allows me say “Cortana, Start Work day” and Cortana ends up opening IE (LMS site), Edge (Helpdesk ticket system), Outlook, Skype for Business, and Microsoft Teams. There is also an End-Workday module which closes these applications.

Wednesday, March 6, 2019

MS-301

MS-301T01

Lab

Module 1

SharePoint 2019 Updates

https://docs.microsoft.com/en-us/OfficeUpdates/sharepoint-updates

Module 3

New-SPContentDatabase -Name WSS_Content_Teams –WebApplication http://teams.adatum.com

New-SPSite -Url http://teams.adatum.com/sites/ModernTeamSite
-ContentDatabase WSS_Content_Teams -Name "Modern Team Site" -OwnerAlias
adatum\Administrator -Template "STS#3"

MS-301T03

Lab

Module 3

App Management

Add-PSSnapin *sharepoint*

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services System"

$amsa = New-SPAppManagementServiceApplication -Name “App Management Service” -DatabaseName “Farm_App_Management” –ApplicationPool $appPool

$amsaProxy = New-SPAppManagementServiceApplicationProxy -Name " App Management Service Proxy" -UseDefaultProxyGroup -ServiceApplication $amsa

Get-SPServiceInstance | Where-Object {$_.TypeName -like "*App Management Service*"} | Start-SPServiceInstance

Tuesday, March 5, 2019

MS-300

MS-300T01

Module 1

1. Sign in to VM as administrative account

2. Install SharePoint Online Management Shell module
a. Open Windows PowerShell and run as administrator

b. Run following command to install SharePoint Online Management Shell
module, and Yes and All to prompt questions

   Install-Module -Name Microsoft.Online.SharePoint.PowerShell

3. Connect to SharePoint Online Service
a. Run the following command in the same PowerShell window as previous step. Please replace the TenanatName to the one you got from exercise 1. Enter the password while got prompt for credential. 

$adminUPN="admin@<TenantName>.onmicrosoft.com" $orgName="<TenantName>" $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password." Connect-SPOService `
    -Url https://$orgName-admin.sharepoint.com -Credential $userCredential 
 
4. Register the site as a hub site
a. Run the following command in the same PowerShell window as previous step

Register-SPOHubSite "https://<TenantName>.sharepoint.com/sites/HRWeb" `
   -Principals admin@<TenantName>.onmicrosoft.com

MS-300T02

Module 2

Term Set Info

Term Set Name,Term Set Description,LCID,Available for Tagging,Term Description,Level 1 Term,Level 2 Term,Level 3 Term,Level 4 Term,Level 5 Term,Level 6 Term,Level 7 Term
Department,"A sample term set, describing a simple department.",,TRUE,Departments,Departments,,,,,,
,,,TRUE,HR department,Departments,HR,,,,,
,,,TRUE,Marketing department,Departments,Marketing,,,,,
,,,TRUE,Engineer department,Departments,Engineer,,,,,

MS-300T02

Module 4

https://sample-videos.com/

Friday, January 25, 2019

Windows–DISM PowerShell Replacement

So you need to find the version of windows on your ISO file but you named it windows.iso … well here is how we solved that using DISM
dism /Get-WimInfo /WimFile:F:\sources\install.esd /index:1
Now using PowerShell
Get-WindowsImage –imagepath .\install.wim
but what if you don’t have the install.wim … look for install.esd instead
Get-WindowsImage –impagepath .\install.esd






















References
https://www.computerworld.com/article/3309257/microsoft-windows/grab-a-free-copy-of-win10-version-1803-and-save-it-for-a-rainy-day.html
https://www.winhelponline.com/blog/iso-find-windows-build-version-edition-using-dism/
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/use-dism-in-windows-powershell-s14

Tuesday, January 8, 2019

Fun PowerShell

Roll fair dice

Input the number of pips on the die
Input the number of rolls

reference doc.microsoft.com
PS /> 1..1200 | ForEach-Object { 1..6 | Get-Random } | Group-Object | Select-Object Name,Count
Name Count
---- -----
1      206
2      199
3      196
4      226
5      185
6      188
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-random?view=powershell-6

Tuesday, December 18, 2018

PowerShell 101 - Basics


How to get Help

https://docs.microsoft.com/en-us/powershell

Help
Get-Help
Help vs Get-Command
search command using Bing or google

Search using https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/?view=powershell-6

How to Edit

Tab Complete
History

What is Piping?

Select
More

example: Get-Process | More
example: Get-Process | Select * | More

example: Get-Command | Measure-Object

Variables?

variables
collections
array
Get-Member

example: $temp = Get-Process
example: $temp | Get-Member
example: $temp = Get-Process[0]


Note if help files are missing run update-help or go here to help online


How to get Help

Help
Get-Help
Help vs Get-Command
search

How to Edit

Tab Complete
History

What is Piping?

Select
More
Measure

Variables?

collections
array
get member

Editor

Command line vs ISE

Keyboard Shortcuts

https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/ise/keyboard-shortcuts-for-the-windows-powershell-ise
https://technet.microsoft.com/en-us/library/ff678293.aspx

Tuesday, December 4, 2018

SharePoint PowerShell 2013 Reference Guide

SharePoint PowerShell from 20331 and 20332

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS –DefaultProxyGroup

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup

Friday, November 30, 2018

Azure and Office 365 PowerShell


Office 365

Recycle Bin - 2019.3
https://lazyadmin.nl/powershell/restore-recycle-bin-sharepoint-online-with-powershell/

Flow - How to Disable the Flow button in SharePoint Online - 2019.3
https://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=786

Useful PowerShell cmdlets to administer Office 365 Groups - 2019.3
https://vigneshsharepointthoughts.com/2018/05/16/useful-powershell-cmdlets-to-administer-office-365-groups/

Teams – 2019.3
http://sharepoint-tricks.com/manage-your-teams-on-microsoft-teams

SharePoint – Site Design - 2019.3
https://drewmadelung.com/powershell-for-sharepoint-site-designs-site-scripts

55238 PowerShell Lab A

New-MsolUser –UserPrincipalName pete@CKXXXX.onmicrosoft.com –DisplayName “Pete Coventry” –FirstName “Pete” –LastName “Coventry” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName ashley@CKXXXX.onmicrosoft.com –DisplayName “Ashley Curtis” –FirstName “Ashley” –LastName “Curtis” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName mark@CKXXXX.onmicrosoft.com –DisplayName “Mark Summers” –FirstName “Mark” –LastName “Summers” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName shannen@CKXXXX.onmicrosoft.com –DisplayName “Shannen Smith” –FirstName “Shannen” –LastName “Smith” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName sarah@CKXXXX.onmicrosoft.com –DisplayName “Sarah Manley” –FirstName “Sarah” –LastName “Manley” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

Get-Msoluser

Get-Msoluser –unlicensedusersonly

Set-MsolUserLicense -UserPrincipalName pete@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense -UserPrincipalName ashely@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense -UserPrincipalName mark@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName sarah@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName shannen@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Get-Msoluser

Additional Learning

$unlicensed = Get-Msoluser –unlicensedusersonly
$license = “CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName $unlisensed[0].userprinciplename–AddLicenses $license

55238 PowerShell Lab B

Connect-SPOService –Url https://CKXXXXX-admin.sharepoint.com –credentialzoe@CKXXXX.onmicrosoft.com

New-SPOSite -Url https://CKXXXX.sharepoint.com/sites/hr -title "HR Home" –Owner zoe@CKXXXX.onmicrosoft.com -storagequota 1024 -Template STS#0

Get-SPOSite

https://drm.combined-knowledge.com/cklabs/spoadmin/labs.zip

Import-Csv .\NewSPOSites.csv| % {New-SPOSite -Owner $_.Owner –StorageQuota $_.StorageQuota -Url $_.Url -NoWait -ResourceQuota $_.ResourceQuota –Template $_.Template -Title $_.Name}

Get-SPOSite

Set-SPOUser -site https://CKXXXX.sharepoint.com/sites/hr –LoginName pete@CKXXXX.onmicrosoft.com -IsSiteCollectionAdmin $True

Get-SPOUser -Site https://CKXXXX.sharepoint.com/sites/hr | where {$_.IsSiteAdmin}

$spoSites=Get-SPOSite | Select *

foreach($spoSite in $spoSites)

{

Write-Host "Admins for " $spoSite.Url -foregroundcolor Yellow

Get-SPOUser -Site $spoSite.Url | where {$_.IsSiteAdmin}

Write-Host

}

Set-SPOSite -identity https://CKXXXX.sharepoint.com/sites/intranet –StorageQuota 15000 -StorageQuotaWarningLevel 13000

$spoSites=Get-SPOSite | Select *

foreach($spoSite in $spoSites)

{

Write-Host "Changing Quota for " $spoSite.Url -foregroundcolor Yellow

Set-SPOSite -identity $spoSite.URL -StorageQuota 12500 -StorageQuotaWarningLevel 11000

Write-Host

}

Remove-SPOSite https://CKXXXX.sharepoint.com/sites/ProjectSite

Remove-SPODeletedSite https://CKXXXX.sharepoint.com/sites/ProjectSite


Legacy – Azure O365

SharePoint Online Management Shell
http://www.microsoft.com/en-us/download/details.aspx?id=35588
Office 365 cmdlets will make working with SharePoint Online very similar to working with SharePoint on-premises.
Creating List and Libraries using CSOM
http://sharepoint-community.net/profiles/blogs/powershell-import-list-items-from-csv-client-object-model

Scripting Guys – Always Great Start to Your Day
 http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/28/manage-office-365-sharepoint-with-modules.aspx
Gary Lapointe – PowerShell Author
http://blog.falchionconsulting.com/index.php/2014/01/announcing-my-custom-sharepoint-online-cmdlets
Create Folder in Office 365
http://www.enjoysharepoint.com/Articles/Details/create-folders-csom-powershell-script-office-365-sharepoint-online-21042.aspx

Windows Azure Active Directory Module for Windows PowerShell

First you need the modules …
Using Server 2012 no issues, install Microsoft Online Services Sign-in Assistant and AD Module, no issues.
http://technet.microsoft.com/en-us/library/jj151815.aspx
I followed this with no luck on Windows 7 on 32 bit, appears there is a bug and the fix is to run the beta software for the Microsoft Online Services Sign-in Assistant. (shaking my head)
http://social.msdn.microsoft.com/Forums/windowsazure/en-US/46a38822-28a4-4abb-b747-96f7db2a2676/cannot-install-azure-active-directory-module-for-windows-powershell-mossia-is-not-installed

Now that is is loaded it is fairly simple to test.  Start my opening the new Icon on your desktop.
You need to set your credentials and pass that to Microsoft Office 365.  Making sure to logon using admin@yourdemodomain.onmicrosoft.com

$msolcred = get-credential
connect-msolservice -credential $msolcred

Now test my simply running a command to get your users.
Get-MsolUser
 
More tests - Admin Roles
Get-MsolRole | select name,description | ft –autosize
 
More Tests – Domain Info
Get-MsolDomain
 
More Tests – Subscription Info
Get-MsolSubscription
Get-MsolAccountSku

SharePoint Online Management Shell


So for SharePoint Online Management Shell the step are very similar to Office 365. First set your variable for both your admin credentials and website.  Next run the connect command both Office 365 and SharePoint Online. Once you successfully run both command you get no errors just a returned prompt.  So here are the commands noting that the domain is contoso.sharepoint.com
Logon to Office 365 with you admin account and go to the admin screen for SharePoint, this account later used for $mycred variable.
 
Look at the admin address since this will give you the right URL to manage and will use for $mysite variable.
Run the following commands in the new SharePoint Online Management Shell
 
$mycred = get-credential
$mysite = ‘https://contoso-admin.sharepoint.com”
connect-msolservice -credential $mycred
connect-SPOService -Url $mysite -credential $mycred

test using the following commands:
get-msoluser
get-sposite

Help


http://powershell.office.com/

Subscription


http://dev.office.com/

Wednesday, February 21, 2018

PowerShell Courses Books Tools and Training

Free Books

List of Free PowerShell eBooks (11-2018)
https://www.hofferle.com/list-of-free-powershell-ebooks/

List of Free Books – PowerShell

 https://cincypowershell.org/Resources/

Huge List of Free Books – Including PowerShell

http://thecloudengineer.blogspot.com/2011/12/sharepointbooks.html

Free Microsoft Books – Including PowerShell

http://thecloudengineer.blogspot.com/2011/12/sharepointbooks.html

Free eBooks – PowerShell

https://powershell.org/category/books

https://leanpub.com/u/devopscollective

Scripting Guy
http://blogs.technet.com/b/heyscriptingguy/

Windows PowerShell Survival Guide (11-2018)
https://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspx

Free Training

PowerShell and Active Directory Essentials

https://info.varonis.com/thank-you/course/powershell

Latest Books Recommended by Students

PowerShell for Dummies
https://www.amazon.com/Windows-PowerShell-Dummies-Steve-Seguis/dp/0470371986/ref=sr_1_1

Learn Windows PowerShell in a Month of Lunches

https://www.amazon.com/Learn-Windows-PowerShell-Month-Lunches/dp/1617294160/ref=sr_1_1

Great list from Ashley McGlone
https://blogs.technet.microsoft.com/ashleymcglone/2016/04/01/powershell-video-training-from-microsoft/   

Examples

Find Duplicate Files With PowerShell (11-2018)
http://blog.codeassassin.com/2007/10/13/find-duplicate-files-with-powershell/

Tools

Idera PowerShell Plus is now free
Free tool to learn and master PowerShell fast

  • Learn PowerShell fast with the interactive learning center
  • Execute PowerShell quickly and accurately with a Windows UI console
  • Access, organize and share pre-loaded scripts from the QuickClick™ library
  • Code & Debug PowerShell 10X faster with the advanced script editor
https://www.idera.com/Free-Tools/PowerShell-Plus/

User Groups


Cincy OH -
http://powershellgroup.org/cincinnati.oh
Columbus OH - http://powershellgroup.org/central.oh

Older Books on PowerShell


General - Must Have!

Automating Microsoft Windows Server 2008 R2 with Windows PowerShell 2.0
Windows PowerShell 2.0 allows you to automate nearly any task for managing Windows Server, going from dozens of clicks to a single command, and repeated tasks to automated tasks. Using screen shots and helpful exercises, this book walks you through the many benefits of automating Windows Server with PowerShell 2.0, such as allowing for scalable, flexible, and rapid deployments and changes; increasing cost effectiveness; providing a timely return on IT investment; lowering labor headcount; creating secure computing environments; and establishing reliable enterprise infrastructures. In addition, real-world examples provide reinforced learning, aimed at ensuring that you work as efficiently and effectively as possible by automating both simple and complex administrative tasks with Powershell 2.0.
Details from
Wiley Publishing  Matt Hester http://blogs.technet.com/b/matthewms/

SharePoint - Must Have!

Automating SharePoint 2010 with Windows PowerShell 2.0
Imagine being able to perform a task that requires dozens of clicks with just a single command, or automate a series of identical tasks rather than repeat them. This book shows you how to do just that?and more?by using Windows PowerShell cmdlets with SharePoint 2010. Focused on everyday and frequently performed tasks, this invaluable guide provides PowerShell solutions for maintaining a SharePoint environment and explains how more than 500 cmdlets that come with SharePoint 2010 allows you to automate just about anything. Step-by-step instructions walk you through the necessary concepts and real-world examples enhance your learning process.
Details from
Amazon  Gary LaPoint http://blog.falchionconsulting.com/

Recommended by students ...

Windows PowerShell 2 For Dummies
Prepare for the future of Microsoft automation with this no-nonsense guide
Windows PowerShell 2 is the scripting language that enables automation within the Windows operating system. Packed with powerful new features, this latest version is complex, and Windows PowerShell 2 For Dummies is the perfect guide to help system administrators get up to speed.
Written by a Microsoft MVP with direct access to the program managers and developers, this book covers every new feature of Windows PowerShell 2 in a friendly, easy-to-follow format.
  • Windows PowerShell 2 is the updated scripting language that enables system administrators to automate Windows operating systems
  • System administrators with limited scripting experience will find this book helps them learn the fundamentals of Windows PowerShell 2 quickly and easily
  • Translates the jargon and complex syntax of Windows PowerShell 2
  • Covers script debugging improvements, the ability to invoke commands remotely, and the new user interface
  • Uses real-world applications to clarify the theory, fundamentals, and techniques of the scripting language
  • Written by a Microsoft MVP with direct access to the developers of Windows PowerShell 2
Windows PowerShell 2 For Dummies makes this tool easily accessible to administrators of every experience level.


Training Courses



10325A Automating Administration with Windows PowerShell 2.0

This course provides students with the knowledge and skills  to utilize Windows PowerShell for administering and automating administration of  Windows based servers. This course is intended for IT Professionals already  experienced in general Windows Server and Windows Client administration,  including Active Directory administration. No prior experience with any version  of Windows PowerShell, or any scripting language, is assumed. Topics covered include:

10961 Automating Administration with Windows PowerShell 3.0
Learn how with Windows PowerShell 3.0, you can remotely manage single or multiple Windows-based servers and automate day-to-day management and administration tasks.
This five day course provides students with the fundamental knowledge and skills to use Windows PowerShell 3.0 for administering and automating administration of Windows based servers. It focuses on primary Windows PowerShell command-line features and techniques, and will provide prerequisite skills supporting many different Microsoft products. This includes Windows Server, Windows Client, Exchange Server, SharePoint Server, SQL Server, System Center, and more. In keeping with that goal, this course will not focus on any one of those products, although Windows Server (which is the common platform for all of those) will serve as the example for the techniques being taught.

MVA


Basic - http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start
Advanced - http://www.microsoftvirtualacademy.com/training-courses/advanced-tools-scripting-with-powershell-3-0-jump-start

Intermediate | Published: 30 July 2013  | Getting Started with Microsoft PowerShell
Instructor(s):
Jason Helmick and Jeffrey Snover


https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276?l=r54IrOWy_2304984382

Friday, December 22, 2017

SharePoint PowerShell 20339 Reference Guide

PowerShell SharePoint Code Examples

Here are examples inspired from the SharePoint Farm course 20339-1/20339-2

20339-1

Module 5: Installing and configuring SharePoint 2016

OOS Basic Setup

On OOS server …

New-OfficeWebAppsFarm -InternalURL “http://$env:COMPUTERNAME” –AllowHttp:$true –EditingEnabled:$true

On SharePoint server …

New-SPWOPIBinding -ServerName NYC-OOS –AllowHTTP:$true
Set-SPWOPIZone -Zone "internal-http"
$config = Get-SPSecurityTokenServiceConfig
$config.AllowOAuthOverHttp = $true
$config.Update()

Module 6 – Web Applications and Site Collections

Site Collection

New-SPContentDatabase -Name WSS_Content_TeamArchive -WebApplication http://teams.contoso.com

New-SPSite -Url "http://teams.contoso.com/team/archive" -ContentDatabase WSS_Content_TeamArchive -Name "Team Archive" -OwnerAlias CONTOSO\Administrator -Template "STS#0"


Module 7 – Service Applications

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS -DefaultProxyGroup

Word Automation

New-ADUser -SamAccountName SPWordAutomation -Name "SP Word Automation" -UserPrincipalName "SPWordAutomation@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoWordAutomationAppPool -Account SPWordAutomation@contoso.com

$WCS = New-SPWordConversionServiceApplication -Name "Contoso Word Automation Service" -ApplicationPool $AppPool -DatabaseName ContosoWordAutomation

20339-2

Module 1

Farm configuration

New-SPConfigurationDatabase –DatabaseServer “ContosoDB” –DatabaseName “SharePoint_Config” –AdministrationContentDatabaseName “SharePoint Farm Content” –Passphrase (Read-Host –Prompt “Enter Farm PassPhrase” –AsSecureString) –FarmCredentials (Get-Credential –Message “Enter Farm Account Credential”) –LocalServerRole “Custom”

To create the ACL resources

Initialize-SPResourceSecurity

Install the required services

Install-SPService

Install the SharePoint features

Install-SPFeature -AllExistingFeatures

Create Central Administration

New-SPCentralAdministration -Port 50000 -WindowsAuthProvider NTLM

Install the Help Collection

Install-SPHelpCollection -All

Complete the installation of Central Administration

Install-SPApplicationContent

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

Search

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

Start-SPEnterpriseSearchServiceInstance $env:COMPUTERNAME

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:COMPUTERNAME

$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name “Search Service Application” -ApplicationPool $saAppPool -DatabaseServer “ContosoDB” -DatabaseName “Farm_SSA”

$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name “Search Service Application Proxy” -SearchApplication $searchServiceApp

[IO.Directory]::CreateDirectory(“c:\spSearchIndex”)

$clone = $searchServiceApp.ActiveTopology.Clone()

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local

New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance -RootDirectory “c:\spSearchIndex”;

New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

$clone.Activate()


User Profile Service

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$upa = New-SPProfileServiceApplication –Name “User Profile Service” -ApplicationPool $saAppPool -ProfileDBName “Farm_UPA_Profile” -ProfileSyncDBServer “ContosoDB” -SocialDBName “Farm_UPA_Social” -SocialDBServer “ContosoDB” -ProfileSyncDBName “Farm_UPA_Sync” -ProfileDBServer “ContosoDB”

New-SPProfileServiceApplicationProxy -Name " User Profile Service Proxy" -ServiceApplication $upa –DefaultProxyGroup

Get-SPServiceInstance | where-object {$_.TypeName -eq “User Profile Service”} | Start-SPServiceInstance

Module 2

Office 365 Prerequisites

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

App Management

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$amsa = New-SPAppManagementServiceApplication -Name “App Management Service” -DatabaseName “Farm_App_Management” –ApplicationPool $appPool

$amsaProxy = New-SPAppManagementServiceApplicationProxy -Name " App Management Service Proxy" -UseDefaultProxyGroup -ServiceApplication $amsa

Get-SPServiceInstance | Where-Object {$_.TypeName -like "*App Management Service*"} | Start-SPServiceInstance

Subscription Service

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$SSSA = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name "Subscription Settings Service"

$sssaProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SSSA

$spInstances = Get-SPServiceInstance; $spInstances.Where{$_.TypeName -like "*Subscription Settings Service*"} | Start-SPServiceInstance


Appendix

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup

Tuesday, November 28, 2017

Windows 10 PowerShell Reference Guide

Course 20697-1 Implementing and Managing Windows 10

Module 3

Get-ExecutionPolicy

Set-ExecutionPolicy Unrestricted

Get-PrinterProperty –PrinterName “HP Photosmart 7520”
Note
: The property named Config:DuplexUnit is set to TRUE.

Set-PrinterProperty –PrinterName “HP Photosmart 7520” –PropertyName “Config:DuplexUnit” –Value FALSE
Note:
You must use all caps for the TRUE or FALSE values.

Get-PrinterProperty –PrinterName “HP Photosmart 7520”
Note:
The property named Config:DuplexUnit is now FALSE.

# *** Answer *** List Running Services in Green

$services = get-service

foreach ($service in $services) {

    if ($service.status –eq “Running”) {

        $color = “Green” }

    Else {

        $color = “Red” }

    write-host $service.Name “ – “ $service.Status –ForegroundColor $color

}

write-host “A total of “ $services.count “services were evaluated”

write-host “Script execution is complete” –ForegroundColor gray –BackgroundColor Black

Additional Notes Try …

$services | Group-Object -Property status

Module 4

Get-NetIPAddress

test-connection LON-DC1

Get-DnsClientCache

Clear-DnsClientCache

test-connection www

Get-DnsClientCache | fl

Resolve-Dnsname LON-DC1 | fl

Module 5

$MaxSize = (Get-PartitionSupportedSize –DriveLetter e).sizeMax
Resize-Partition –DriveLetter e –Size $MaxSize

Clear-Disk –Number 1 –RemoveData
Note: Delete all partitions from disk

Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR

Module 6

Install-WindowsFeature FS-SyncShareService
Note: After the feature installs, you will receive a warning message because Windows automatic updating is not enabled. You can ignore the warning.

Module 7

add-appxpackage \\lon-dc1\apps\app1.appx

Module 8

Sorry but no noteworthy PowerShell

Module 9

Invoke-Gpupdate –force

Module 10

Run Get-NetIPsecMainModeSA

Note: To examine the Main Mode Security Associations (SAs), at the Windows PowerShell prompt, type the following cmdlet, and then press Enter:
Get-NetIPsecMainModeSA

Run Get-NetIPsecQuickModeSA

Note: To examine the Quick Mode SAs, at the Windows PowerShell prompt, type the following cmdlet, and then press Enter:
Get-NetIPsecQuickModeSA

Module 11

Sorry but no noteworthy PowerShell

Module 12

Sorry but no noteworthy PowerShell

Tuesday, June 27, 2017

SharePoint Remote PowerShell

Yes it is possible, Please follow the steps below.

On the client machine (the management server):

  • Enable-WSManCredSSP -Role Client -DelegateComputer * -Force
  • Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentials -Name WSMan -Value WSMAN/*

  • Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain -Name WSMan -Value WSMAN/*

On the SharePoint server:

  • Enable-PSRemoting -Force

  • Enable-WSManCredSSP -Role Server -Force

Afterwards it is possible to connect to the server using PowerShell from your management server, using the following cmdlet:

  • Enter-PSSession SPServer -Authentication CredSSP -Credential DOMAIN\username
  • Add the SharePoint PowerShell SnapIn
  • Add-PSSnapIn Microsoft.SharePoint.PowerShell

To see if it works, run a simple SharePoint cmdlet:

Get-SPSite

PowerShell Remoting for SharePoint

Original Ref

https://blogs.msdn.microsoft.com/besidethepoint/2010/05/26/powershell-remoting-for-sharepoint/

Wednesday, June 7, 2017

Windows 10 Troubleshooting PowerShell Reference Guide

Course 10982 – Windows 10 Troubleshooting

Windows PowerShell Remoting

Invoke-Command –ComputerName LON-CL1 –ScriptBlock {Get-EventLog –log system}

$s = New-PSWorkflowSession –ComputerName LON-CL1

Enter-PSSession $s

Get-Command

Invoke-Command -Session $s -ScriptBlock {$c = Get-command}

Invoke-Command -Session $s -ScriptBlock {$c.count}

Invoke-Command -ComputerName LON-CL1, LON-CL3 -ScriptBlock {Get-Culture}

$s = New-PSWorkflowSession -ComputerName LON-CL1, LON-CL3

Invoke-Command -Session $s -ScriptBlock {$c = Get-command}

Invoke-Command -Session $s -ScriptBlock {$c.count}

ISE Remoting

Get-Service | Where-Object {$_.Status -eq “Running”}

Get-NetIPConfiguration

Restart-Computer -Force