Connect to Office 365 with PowerShell
![qa-featured](https://www.techyv.com/sites/default/users/superadmin/qa-featured-300x270.png)
I was facing a problem regarding the connection of Office 365 with Powershell. Can you help me with connecting it? Thanks in advance.
![](https://techyv.com/sites/default/2016/10/techpedia_logo.png)
I was facing a problem regarding the connection of Office 365 with Powershell. Can you help me with connecting it? Thanks in advance.
Hello. I hope you will find this post helpful. So, The web admin interface for Office 365 is very good, but sometimes PowerShell is more suited. Here we will go through every step for connection to Office 365 with PowerShell.
Step 1- Firstly, open the PowerShell session.
Step 2- Now, you have to store your Credentials in a variable:
Step 3- Now enter your Office 365 Credentials when prompted:
Step 4- Create a new PowerShell session from the Office 365 server:
$Session=New-PSSessions-ConfigurationName
Step 5- Import the session:
Import-PSSession $Session
Step 6- Now, you can run any command you need.
Step 7- When you have finished, remove the session you created in step 2:
Remove-PSSession $Session
*Here is the complete code to connect to Office 365 with PowerShell
$Cred= Get-Credential
$Session= New-PSSession-ConfigurationName
Import-PSSession $Session
#You can run any command you want here
Remove-PSSession $Session