First Time Use of PowerShell
A PowerShell with SharePoint tutorial
PowerShell
scripts are created in the app PowerShell ISE, that is included
in Windows. In the demo below, Peter Kalmström shows how
to find PowerShell ISE and how to write a script that changes
the default execution policy.
Peter starts with a short overview of how the PowerShell
ISE app is used. After that he writes a line of script and
runs it.
By default, you are not allowed to run scripts on a Windows
computer, so before you can run any scripts you must allow
that. As this is a PowerShell tutorial, Peter will of course
do that with a script, and that is the first script you
must run when you start using PowerShell.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Before you start using PowerShell with SharePoint, you should
also install the SharePointPnPPowerShell module. This is
a library of PowerShell commands that allows you to perform
complex provisioning and artifact management actions towards
SharePoint.
Install-Module SharePointPnPPowerShellOnline
In the demo below, Peter Kalmström shows one way of downloading
and installing SharePointPnPPowerShell. He also explains
how to connect the SharePointPnPPowerShell module to a SharePoint
site and check the connection.
When SharePointPnPPowerShell has been installed on the computer,
it is imported to PowerShell each time it should be used
and connected to the SharePoint site you want to work with.
Import-Module SharePointPnPPowerShellOnline
Connect-PnPOnline PATH
You will find more detailed explanations in
the
book.
In the
next
article, we will see how you can avoid logging in to
SharePoint each time you are running a PowerShell script.
|