I’ve had a request to consolidate all of my little script examples into a single blog post. While I’m not starting out with all 101 examples, I will continually update this post with scripts ideas and examples. Enjoy.
Group Membership Needed to get all domain accounts underneath my manager’s direct reports distribution list:
Query Event Log Pass some parameters to the event log and show results in a GridView. This allows for filtered results, but also allows for additional sorting and filtering after the query executes. This particular script gets any source like ‘*sharepoint*’ in the Application log and returns the last 20 results.
File Merge I used this little script to read a number of log files into a single file. (i.e. Merge)
Working with XML Use this as a starter script to reading XML files down to a specific node
Disable Loopback Check Anyone that builds their own VMs knows the trouble this can cause. Usually, the resulting error is an HTTP 401.
Change the default listening port of Remote Desktop I often remote desktop into my computer at home through the internet. This script will allow you to change the default listening port of Remote Desktop from the standard 3389 to a different port. This may be helpful if you would like to remote into different computers or for added security.
Feature Module Elements in XML Automating the creation of the <File Url…. /> node under a module <File Url=”SiteCollectionImages/logo.gif” Type=”GhostableInLibrary” />
Show All Features Definitions in a GridView or CSV Shows all features in your farm in a nice, easy to read gridview where you can perform additional filtering and searches. (toggle the “Query” option to add specific filters)
Create a new Window and display a TreeView control This script uses SharePoint API to get a list of sites and show them in a WPF TreeView control
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="400" Width="500"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="200*" /> </Grid.ColumnDefinitions> <TreeView Grid.Column="1" Name="treeview1" /> </Grid> </Window> treeview.ps1
Add-Type -AssemblyName presentationframework
$dir = '.' # Create WPF Form from XAML file and bind Controls to variables $path = Resolve-Path $dir $Form=[Windows.Markup.XamlReader]::Load([IO.File]::OpenText('c:\users\ekraus\Desktop\window.xaml').basestream) $ListBox = $form.FindName('listBox') $RichTextBox = $form.FindName('richTextBox1') # Fill ListBox
dir *.ps1 |% { $li = new-Object Windows.Controls.ListBoxItem $li.Content = $_.name $li.Tag= $_.fullname $listbox.Items.Add($LI) } # Add Handler to Read File $ListBox.add_MouseDoubleClick({ $RichTextBox.SelectAll() $RichTextBox.Selection.Text = gc $this.Selecteditem.Tag })
# Invoke Form $Form.ShowDialog() | out-null
PingBack from http://www.anith.com/?p=4046
I’ve posted this under my 101 Uses for PowerShell , but I thought it was so helpful that it deserved
I’ve had a request to consolidate all of my little script examples into a single blog post.  While