Fun Finds
Calendar
https://github.com/jdhitsolutions/PSCalendar
Excel
https://github.com/dfinke/ImportExcel
https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/25/introducing-the-powershell-excel-module-2/
Calendar
https://github.com/jdhitsolutions/PSCalendar
Excel
https://github.com/dfinke/ImportExcel
https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/25/introducing-the-powershell-excel-module-2/
Here are examples inspired from the SharePoint Farm course 20339-1/20339-2
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()
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"
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
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
$appPoolCred = Get-Credential –Credential “contoso\spServices”
$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred
$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”
$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()
$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
Office 365 Prerequisites
$appPoolCred = Get-Credential –Credential “contoso\spServices”
$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred
$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”
$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
$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
State Service
$serviceApp = New-SPStateServiceApplication -Name "StateService-App"
New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp
New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup
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 4Get-NetIPAddress
test-connection LON-DC1
Get-DnsClientCache
Clear-DnsClientCache
test-connection www
Get-DnsClientCache | fl
Resolve-Dnsname LON-DC1 | fl
$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
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.
add-appxpackage \\lon-dc1\apps\app1.appx
Sorry but no noteworthy PowerShell
Invoke-Gpupdate –force
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
Sorry but no noteworthy PowerShell
Sorry but no noteworthy PowerShell
Yes it is possible, Please follow the steps below.
On the client machine (the management server):
Enable-WSManCredSSP -Role Client -DelegateComputer * -ForceSet-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:
Add the SharePoint PowerShell SnapInAdd-PSSnapIn Microsoft.SharePoint.PowerShellTo see if it works, run a simple SharePoint cmdlet:
Get-SPSitePowerShell Remoting for SharePoint
Original Ref
https://blogs.msdn.microsoft.com/besidethepoint/2010/05/26/powershell-remoting-for-sharepoint/