Sunday, 31 January 2016

OneLiners for PowerShell with SharePoint Online

At last, I got a SharePoint Online setup for free for now.
Then, I downloaded the SharePoint Online Management Shell from https://www.microsoft.com/en-us/download/details.aspx?id=35588 by choosing the 64 bit version. You may check the version of your Windows by Right Clicking the leftmost bottom corner and choosing System ->System Type.
Below is the first command to connect to SharePoint Online:
Connect-SPOService -Url "https://<yourname>-admin.sharepoint.com" -Credential <alias>@<yourname>.onmicrosoft.com
Examples:
Connect-SPOService -Url "https://spthangu-admin.sharepoint.com" -Credential explore@spthangu.onmicrosoft.com

Ensure you Run the Powershell as Administrator(Shift+Right Click->Run ISE as Administrator)
and use the admin url of the SharePoint site and not the SharePoint site.

The above command to connect must be run before you execute any of the below One Liners:
#View SharePoint Online organization properties
Get-SPOTenant
#View App Errors(Get the number after "@" sysmbol of the App from Site Setting->App #Permissions
Get-SPOAppErrors -ProductId 067e1a0e-58d2-4366-b56f-5bf9b563b284
#View App Info
Get-SPOAppInfo -Name "Microsoft.SharePoint"
#Get Deleted Site
Get-SPODeletedSite
#Get External User
Get-SPOExternalUser
#Get Migration Job Status and Progress
Get-SPOMigrationJobProgress
Get-SPOMigrationJobStatus -TargetWebUrl https://spthangu.sharepoint.com
#View all details of a SharePoint site
Get-SPOSite -Identity "https://spthangu.sharepoint.com"|Format-List
#Display the count of sites under a site collection
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").WebsCount
#Get the Title of Site Collection
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").Title
#View the Sharing capability
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").SharingCapability
#View the last content modified date
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").LastContentModifiedDate
#View LocaID or language settings 1033 English
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").LocaleId
#View LockState(UnLock)
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").LockState
#View Site Admninistrator/Owner
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").Owner
#View if PWA is enabled
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").PWAEnabled
#Check Status of Site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").Status
#View Site Template
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").Template
#View URL of a site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").Url
#View Resource Quota
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").ResourceQuota
#View Resource Warning Level of a Site[255]
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").ResourceQuotaWarningLevel
#View average Resource Usage of a site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").ResourceUsageAverage
#View Current Resource Usage of a site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").ResourceUsageCurrent
#View Sandbox capacity of a site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").SandboxedCodeActivationCapability
#View Storage Quota of a Site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").StorageQuota
#View Storage Quota of a Site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").StorageQuotaType
#View Storage Quota Warning level of a site
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").StorageQuotaWarningLevel
#View Current Storage Usage
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").StorageUsageCurrent

#View count of Webs
(Get-SPOSite -Identity "https://spthangu.sharepoint.com").WebsCount
#View Site Groups
Get-SPOSiteGroup -Site "https://spthangu.sharepoint.com"
#View only NAmes
Get-SPOSiteGroup -Site https://spthangu.sharepoint.com | select LoginName,Roles
 
#View Users for Group
Get-SPOSiteGroup -Site https://spthangu.sharepoint.com | select LoginName,Users | format-table -Wrap

#Tenant Properties
 (Get-SPOTenant).StorageQuota
(Get-SPOTenant).StorageQuotaAllocated
(Get-SPOTenant).ResourceQuota
(Get-SPOTenant).ResourceQuotaAllocated
(Get-SPOTenant).OneDriveStorageQuota
(Get-SPOTenant).CompatibilityRange
(Get-SPOTenant).ExternalServicesEnabled
(Get-SPOTenant).NoAccessRedirectUrl
(Get-SPOTenant).SharingCapabilit
(Get-SPOTenant).DisplayStartASiteOption
"Tenant Properties"
"StartASiteFormUrl for Tenant"
(Get-SPOTenant).StartASiteFormUrl
" ShowEveryoneClaim for Tenant?"
(Get-SPOTenant).ShowEveryoneClaim 
"ShowAllUsersClaim for Tenant?"
(Get-SPOTenant).ShowAllUsersClaim
" OfficeClientADALDisabled Status for Tenant?"
(Get-SPOTenant).OfficeClientADALDisabled
"LegacyAuthProtocolsEnabled for Tenant?"
(Get-SPOTenant).LegacyAuthProtocolsEnabled
"ShowEveryoneExceptExternalUsersClaim for Tenant?"
(Get-SPOTenant).ShowEveryoneExceptExternalUsersClaim
"SearchResolveExactEmailOrUPN for Tenant?"
(Get-SPOTenant).SearchResolveExactEmailOrUPN   
"    RequireAcceptingAccountMatchInvitedAccount for Tenant?"
(Get-SPOTenant).RequireAcceptingAccountMatchInvitedAccount
"ProvisionSharedWithEveryoneFolder for Tenant?"
(Get-SPOTenant).ProvisionSharedWithEveryoneFolder 
"ProvisionSharedWithEveryoneFolder for Tenant?"     
(Get-SPOTenant).SignInAccelerationDomain
"UsePersistentCookiesForExplorerView    for Tenant?"            
(Get-SPOTenant).UsePersistentCookiesForExplorerView 
"BccExternalSharingInvitations    for Tenant?"
(Get-SPOTenant).BccExternalSharingInvitations  
"    BccExternalSharingInvitationsList      for Tenant?"
(Get-SPOTenant).BccExternalSharingInvitationsList
"  UserVoiceForFeedbackEnabled      for Tenant?"
(Get-SPOTenant).UserVoiceForFeedbackEnabled
"            RequireAnonymousLinksExpireInDays    for Tenant?"
(Get-SPOTenant).RequireAnonymousLinksExpireInDays   for Tenant?"
"       SharingAllowedDomainList  for Tenant?"
(Get-SPOTenant).SharingAllowedDomainList 
"SharingBlockedDomainList      for Tenant? "         
(Get-SPOTenant).SharingBlockedDomainList 
"    SharingDomainRestrictionMode     for Tenant?"       
(Get-SPOTenant).SharingDomainRestrictionMode             
"OneDriveForGuestsEnabled for Tenant?"
(Get-SPOTenant).OneDriveForGuestsEnabled                 
Get-SPOTenantLogEntry
#Last Login Time
Get-SPOTenantLogLastAvailableTimeInUtc
Get-SPOTenantSyncClientRestriction

Get-SPOWebTemplate
Get-SPOWebTemplate|select Title

#In PRogres#
$spoSite = Get-SPOSite -Identity "https://spthangu.sharepoint.com"
#View all Team Sites
$spoSite | ?{$_.Template -like "*STS#0" -or $_.Template -like "*EHS#1*"}
#View all Blogs
$spoSite | ?{$_.Template -like "*BLOG#0" }
#Document Center
$spoSite | ?{$_.Template -like "*BDR#0" }
#Developer Site
$spoSite | ?{$_.Template -like "*DEV#0" }
#Records Center
$spoSite | ?{$_.Template -like "*OFFILE#1" }
#BI
$spoSite | ?{$_.Template -like "*BICenterSite#0" }
#Search
$spoSite | ?{$_.Template -like "*SRCHCEN#0" }
#Publishing
$spoSite | ?{$_.Template -like "*BLANKINTERNETCONTAINER#0"}
#Wiki
$spoSite | ?{$_.Template -like "*ENTERWIKI#0"}
#Project Site
$spoSite | ?{$_.Template -like "*PROJECTSITE#0"}

#View all Product Catalog
$spoSite | ?{$_.Template -like "*PRODUCTCATALOG#0"}
#View all Community Site
$spoSite | ?{$_.Template -like "*COMMUNITY#0" }
#Community POrtal
$spoSite | ?{$_.Template -like "*COMMUNITYPORTAL#0" }
#Search Site
$spoSite | ?{$_.Template -like "*SRCHCENTERLITE#0 " }
#Visio Process Repository
$spoSite | ?{$_.Template -like "*visprus#0" }

#Get commands Over

#Below are New Type Commands
#Create a new Site Collection
$Url = "https://spthangu.sharepoint.com/sites/Prod"
$Title = "Production Site"
$template = "STS#0"
New-SPOSite -Url $Url -Owner $User -Title $Title -Template $template -StorageQuota 10000
#View newly created site
$sites=Get-SPOSite
$sites

Below are the commonly used command lets from Microsoft for SharePoint Online:
User management cmdlets
CmdletDescription
Add-SPOUser Adds an existing Office 365 user or an Office 365 security group to a SharePoint group.
Get-SPOUser Returns the SharePoint Online user or security group accounts that match a given search criteria.
Remove-SPOUser Removes a user or a security group from a site collection or a group.
Set-SPOUser Configures properties on an existing user.
Get-SPOExternalUser Returns external users that are located in the tenant's folder based on specified criteria.
Remove-SPOExternalUser Permanently removes a collection of external users from the tenant’s folder.
Top of Page

User group management cmdlets

CmdletDescription
Get-SPOSiteGroup Gets all the groups on the specified site collection.
New-SPOSiteGroup Creates a new group in a SharePoint Online site collection.
Remove-SPOSiteGroup Removes a SharePoint Online group from a site collection.
Set-SPOSiteGroup Updates the SharePoint Online owner and permission levels on a group inside a site collection.
Top of Page

Upgrade cmdlets

CmdletDescription
Upgrade-SPOSite Starts the upgrade process on a site collection.
Request-SPOUpgradeEvaluationSite Requests creation of a copy of an existing site collection for the purposes of validating the effects of upgrade without affecting the original site.
Top of Page

Site collection management cmdlets

CmdletDescription
Get-SPODeletedSite Returns all deleted site collections from the Recycle Bin
Get-SPOSite Returns one or more site collections.
New-SPOSite Creates a new SharePoint Online site collection for the current company.
Remove-SPODeletedSite Removes a SharePoint Online deleted site collection from the Recycle Bin.
Remove-SPOSite Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.
Repair-SPOSite Checks and repairs the site collection and its contents.
Restore-SPODeletedSite Restores a SharePoint Online deleted site collection from the Recycle Bin.
Set-SPOSite Sets or updates one or more properties' values for a site collection.
Test-SPOSite Tests a SharePoint Online site collection.
Top of Page

Service connection and disconnection cmdlets

CmdletDescription
Connect-SPOService Connects a SharePoint Online global administrator to a SharePoint Online connection; that is, connects the administrator to the SharePoint Online Administration Center.

This cmdlet must be run before any other SharePoint Online cmdlets can run.
Disconnect-SPOService Disconnects from a SharePoint Online service.

Organization-level monitoring and management cmdlets

CmdletDescription
Get-SPOAppErrors Returns application errors.
Get-SPOAppInfo Returns all installed applications.
Get-SPOTenant Returns SharePoint Online organization properties.
Get-SPOTenantLogEntry Retrieves SharePoint Online company logs.
Get-SPOTenantLogLastAvailableTimeInUtc Returns the time when the SharePoint Online organization logs are collected.
Get-SPOWebTemplate Displays all site templates that match the given identity.
Set-SPOTenant Sets properties on the SharePoint Online organization.


References
https://support.office.com/en-us/article/Introduction-to-the-SharePoint-Online-Management-Shell-c16941c3-19b4-4710-8056-34c034493429#__upgrade_cmdlets

Friday, 29 January 2016

OneLiners in Powershell with SharePoint for Features

#Get details of a specific feature like AdminLinks
Get-SPFeature -Identity "AdminLinks"
#Get SP 2010 features
Get-SPFeature -CompatibilityLevel 14
#Get features scoped at farm level
Get-SPFeature -Farm
#Get all properties of first feature
Get-SPFeature | select -Property * -first 1
#Get all hidden features
Get-SPFeature | ?{$_.Hidden -eq $true} | select DisplayName,ID,RootDirectory
#Get count of all features
Get-SPFeature |measure

OneLiners in Powershell with SharePoint for Excel Services

#ExcelService
Get-SPExcelServiceApplication
#Get Excel BI Server
Get-SPExcelServiceApplication | Get-SPExcelBIServer
#Get Excel Bloacked File type
Get-SPExcelServiceApplication | Get-SPExcelBlockedFileType
#Get Excel Data Connection Library
Get-SPExcelServiceApplication | Get-SPExcelDataConnectionLibrary
#Get Excel Data Provider
Get-SPExcelServiceApplication | Get-SPExcelDataProvider
#Get Excel File Location
Get-SPExcelServiceApplication | Get-SPExcelFileLocation
#Get Excel User Defined file
Get-SPExcelServiceApplication | Get-SPExcelUserDefinedFunction

Thursday, 28 January 2016

One Liners for PowerShell with SharePoint for Diagnostics

#ULS diagnostic configuration values of the farm
Get-SPDiagnosticConfig
#View log location
Get-SPDiagnosticConfig|select LogLocation
#View the Number of Days to keep log
Get-SPDiagnosticConfig|select DaysToKeepLogs
#View diagnostics performance counter
Get-SPDiagnosticsPerformanceCounter
#returns all the diagnostics providers in the farm
Get-SPDiagnosticsProvider
#returns the Distributed Cache client settings for DistributedLogonTokenCache.
Get-SPDistributedCacheClientSetting -ContainerType DistributedLogonTokenCache

Wednesday, 27 January 2016

Oneliners for Powershell with SharePoint InfoPath Form Services

#Get the infopath form settings for entire farm
Get-SPInfoPathFormsService
#Get all udc file
Get-SPDataConnectionFile
#Get data connection dependent file
Get-SPDataConnectionFileDependent
#Get InfoPath form templates
Get-SPInfoPathFormTemplate
#Get a list of user agents in the entire farm
Get-SPInfoPathUserAgent
#Get web service proxy for a web application
Get-SPInfoPathWebServiceProxy -Identity "http://w15-sp"

Tuesday, 26 January 2016

OneLiners in Powershell with Sharepoint for Content Deployment


# Get Content Deployment Job details

Get-SPContentDeploymentJob

#Get Content Deployment Path

Get-SPContentDeploymentPath

One Liners in SharePoint for Databases


#Get the database servers related to SQL Server Reporting Services

Get-SPDatabase | ?{$_.Name -like "SQL Server Reporting Services*"}|select Name,DatabaseConnectionstring

#Get all Sharepoint Content Databases

Get-SPDatabase

#View all content database

Get-SPDatabase |select TYpe  -Unique

#View all servers hosting SharePoint content database

Get-SPDatabase |select Server -Unique

#View details of Managed Metadata service

Get-SPDatabase | ?{$_.Name -like "*Managed Metadata*"}|Format-List

#Scaled Out Database for Service Applications
#View all scaled out database for a service application
#example gets all scale-out databases for the given service application by using the $serviceApplication
#variable.
$serviceApplication = Get-SPServiceApplication -Name "App Management Service"
Get-SPScaleOutDatabase -ServiceApplication $serviceApplication
#View Name of the Scale out Database
(Get-SPScaleOutDatabase -ServiceApplication $serviceApplication).Name
#View Database Connection String of Scale Out Database
$dbConnection=(Get-SPScaleOutDatabase -ServiceApplication $serviceApplication).DatabaseConnectionString
Get-SPScaleOutDatabaseDataState -ConnectionString $dbConnection
#Get all scale out inconsistencies for the given service application
Get-SPScaleOutDatabaseInconsistency -ServiceApplication $serviceApplication
#View the 10 most recent scale out log entries for the given App Service Application
$serviceApplication.Databases |Get-SPScaleOutDatabaseLogEntry -Count 10
#Server Scale Out Database
 #View Scale out databse of all Service Aplication
$serviceApp = Get-SPServiceApplication
for ($i = 0; $i -lt $serviceApp.Count; $i++)
{
  Get-SPServerScaleOutDatabase -ServiceApplication $serviceApp[$i] 
}
#View for Search App Server Scale out database
Get-SPServerScaleOutDatabase -ServiceApplication (Get-SPServiceApplication -Name "Search Service Application")
#Two line version
$searchApp= Get-SPServiceApplication -Name "Search Service Application"
$serverScaleDB=Get-SPServerScaleOutDatabase -ServiceApplication $searchApp
#database Connection string
$dbString = (Get-SPServerScaleOutDatabase -ServiceApplication $searchApp).DatabaseConnectionString
#View DB Name
(Get-SPServerScaleOutDatabase -ServiceApplication $searchApp).DisplayName
#View Database State
#One Line
Get-SPServerScaleOutDatabaseDataState -ConnectionString (Get-SPServerScaleOutDatabase -ServiceApplication $searchApp).DatabaseConnectionString
#Two Line
$dbString = (Get-SPServerScaleOutDatabase -ServiceApplication $searchApp).DatabaseConnectionString
 Get-SPServerScaleOutDatabaseDataState -ConnectionString $dbString
 #View Database Inconsistency
 #One Line
 Get-SPServerScaleOutDatabaseInconsistency -ServiceApplication (Get-SPServiceApplication -Name "Search Service Application")
 #Two Line
 Get-SPServerScaleOutDatabaseInconsistency -ServiceApplication $searchApp
 #Get 10 entriesLog Entry for Server Scale out database
 #One Line
 Get-SPServerScaleOutDatabaseLogEntry -Database (Get-SPServerScaleOutDatabase -ServiceApplication  (Get-SPServiceApplication -Name "Search Service Application")) -Count 10
 #Two line version
 $serverScaleDB=Get-SPServerScaleOutDatabase -ServiceApplication $searchApp
 Get-SPServerScaleOutDatabaseLogEntry -Database $serverScaleDB -Count 10