Как запустить сценарий power shell в share point

Step 1: Install the necessary PowerShell Modules for SharePoint Online

Step 2: Use PowerShell ISE to run your PowerShell scripts for SharePoint Online

Operating systems Windows 7, Windows 2012, and later come with PowerShell ISE pre-installed at “C:\WINDOWS\system32\WindowsPowerShell\v1.0”. On earlier versions, such as Windows Server 2008, you must add PowerShell ISE through Windows features if it is not already installed.

Set Execution Policy:

So, run “Set-ExecutionPolicy RemoteSigned” Once!

  1. Go to Start >> Type “PowerShell ISE”.
    sharepoint online how to run powershell script
  2. Right-click and Open PowerShell ISE with “Run as Administrator” if you have UAC enabled.
  3. Now, You can start writing your PowerShell script or copy-paste the script and then click on the “Run Script” button from the toolbar. (Shortcut key: F5)
    how to run a powershell script for sharepoint online

Any output from your script will appear in the output window below the script editor. You can also use Visual Studio Code to execute PowerShell scripts.

How to run a ps1 file in SharePoint Online Management Shell?

  1. Start SharePoint Online Management Shell >> Navigate to the folder where your scripts are saved.
  2. Just type the name of the script file (Use the “tab” key to get the tab-completion of the file name or manually enter “.\<filename>.ps1”) and hit enter. E.g. We have a PowerShell script “Get-SPODeletedSites.ps1” saved in folder “C:\Scripts” that lists all deleted sites in the tenant.
    how to run ps1 file in sharepoint online management shell
How to Run a PowerShell script

How do I run a ps1 script from the command line?

To execute a PowerShell script from the command line, use: PowerShell <Your-Script-path>

Как запустить сценарий power shell в share point
#Connect to SharePoint Online Admin center
Connect-SPOService -URL "https://YourDomain-admin.sharepoint.com" -Credential (Get-Credential)
#Get All Site collections
Get-SPOSite
#Get all SharePoint Online users from site
Get-SPOUser -site "https://salaudeen.sharepoint.com/sites/retail"