Wednesday, 9 July 2014

Powershell; Write a file and open it

I have found this code quite helpful in debugging - especially trying to look through a large xml schema file for a SharePoint list.

$fileName = "myFile.txt"

# Write some variable property to a file
$web = Get-SPWeb "http://blah.com"
$list = $web.Lists["My List"]
$list.SchemaXml > $fileName

# Open the file in notepad
 Start-Process notepad  -ArgumentList $fileName

No comments:

Post a comment