Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Saturday, March 11, 2017

Automate Office 365 PowerShell in Azure

One of my clients who's using Office 365 had a requirement to execute a PowerShell script on a predefined schedule. This can be achieved in many different ways. You can even automate a script using Windows scheduler. But what I'm going to talk about is a, how to automate a script using Azure Automation. As a prerequisite You must have a Azure.

Log in to your Azure tenant and create a Azure Automation Account.


Create an account.

Next step is to select the necessary PowerShell Module. My PowerShell script was based on SharePointPnPPowerShellOnline. You can simply go to the Modules section, search for the relevant module.

and import.

As you are executing the script remotely, you have to store a users credentials. Hopefully not as plain text in the script. :) Select the Credentials and add the username and the password.


Next is to add your script by selecting Runbooks and adding one.

Place your script in the editor. Also make sure to add your stored credentials as shown in the below screen. You can create a variable from the credentials and pass it to your command.

 $credentials = Get-AutomationPSCredential -Name 'Quicksilver'  

Save & Publish. Next go to the Schedule and create a new schedule for your Runbook.
Happy days!! :)

Tuesday, April 23, 2013

Using PowerShell with Office 365


Given below are the quick steps to connect to your Office 365 site with PowerShell. As the first thing you need to download "SharePoint Online Management Shell". Get the correct version (x64 or x86) and run the setup.

Then run SharePoint Management Shell (if you have SharePoint in your machine) or SharePoint Online Management Shell.
In my case I already have a SharePoint Online site, if you don't, go to office.microsoft.com and give it a try.
After that go to the admin site and check the availability as it's the admin URL you need to connect to with the Connect-SPOService cmdlet.
With the credential parameter you need to pass a user with admin privileges to your Office 365 site. If it's one of your domain yours, make sure your domain is connected to the office 365 environment with ADFS.
It will ask for your password.
OK, the next thing is to find out the stuff you can do with PowerShell in O365. Simple, type cmdlet help SPO or Get-Command -Module Microsoft.Online.SharePoint.PowerShell in shell window.
Simply, you are through. Try out the listed cmdlets.


Tuesday, May 25, 2010

SharePoint 2010 PowerShell Commands

I was playing with some PowerShell Commends. Suddenly came to my mind, how to get the whole SharePoint 2010 related PowerShell Commands. Simple as given below. smile_wink
Open the PowerShell Window (aka SharePoint 2010 Management Shell), type the command…

Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” | select name, definition | format-list > C:\SP2010_PowerShell_Commands.txt

image

Have fun with PowerShell.