In this recipe, we'll ensure your development environment is configured properly.
To complete the recipes in this book, it's assumed you're running a system with SharePoint 2010 Server Standard installed. If not, it is recommended you download and install the 2010 Information Worker Demonstration and Evaluation Virtual Machine (RTM) Virtual Machine environment, if you do not have a compatible system set up. For the most current link to download this virtual environment, search Microsoft Download Center with the keyword 2010 IW demo RTM.
By downloading the preceding environment, you will ensure all of the configurations and setups have been performed and your system is ready for using PowerShell with SharePoint. Whether you're using your own or a downloaded Virtual Machine, let's ensure PowerShell is enabled in your environment.
Let's see how you can get your virtual environment configured and run your first script using the following steps:
Get-ExecutionPolicy
and press Enter on your keyboard. PowerShell may return a value of Restricted
. Set-ExecutionPolicy Unrestricted
and hit Enter.Get-SPSite | Where-Object {$_.Url -eq "http://intranet.contoso.com"}
On Windows 2008 Server, PowerShell script execution policy is set to restrict script execution by default. As an administrator, you can choose to allow script execution by calling the Set-ExecutionPolicy Unrestricted
command.
Once script execution is not restricted, we run a PowerShell command enumerating all of the SharePoint sites with the http://intranet.contoso.com URL. This assumes you have an existing site collection with such a URL. If you're using the downloadable environment from above, the site collection will be already set up for you. If you're running a site collection with a different URL, feel free to replace the value in this example.
3.142.174.55