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