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!
- Go to Start >> Type “PowerShell ISE”.

- Right-click and Open PowerShell ISE with “Run as Administrator” if you have UAC enabled.
- 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)

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?
- Start SharePoint Online Management Shell >> Navigate to the folder where your scripts are saved.
- 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 do I run a ps1 script from the command line?
To execute a PowerShell script from the command line, use: PowerShell <Your-Script-path>

#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"




