http://mikefrobbins.com/2014/04/06/how-to-install-the-preview-version-of-powershell-version-5/
Friday, April 11, 2014
Friday, December 13, 2013
Great PowerShell Site List
Monthly Power Tips
http://powershell.com/cs/media/g/powertipsmonthly2013/default.aspx
List of cmdlets
http://technet.microsoft.com/en-us/library/ee829690.aspx
Good list of real-world PowerShell scripts (windows)
http://www.youdidwhatwithtsql.com/
From Microsoft
www.codeplex.com
Tuesday, December 3, 2013
Remove PowerShell Object
I was working with SharePoint and found an object that I needed to delete
NOTE that lega… is the friendly name. Well not really. On close examination appears that the name was corrupt. The name was lega … with more info.
So using a where-object I gathered a couple of objects and saved as an array.
Then deleted the first object in the array using the name property.
HTH
Wednesday, May 22, 2013
Hyper-V PowerShell
UPDATE … more from Bill Baer
http://blogs.technet.com/b/wbaer/archive/2014/03/21/quick-starting-demos-with-windows-powershell.aspx
Learning to use PowerShell to manage your Hyper-V environment?
Simple Management
First type Get-vm (note if module is not loaded type import-module hyperv)Now I notice a column for state so I just want the running vms so
type Get-vm | where {$_.state –eq ‘running’} (older PS)
type Get-vm | state –eq ‘running’ (using new PS3.0)
How I need to shutdown the running vm’s so
type Get-vm | state –eq ‘running’ | stop-vm
Start VM’s
So you need to start a VM first get a listget-vm
Then sort based on name using like or contains. You can use -like for wildcards, –contain for exact matches, or –ccontain for case sensitive exact matching.
For my scenario, it is best to use –like in my where cmdlet.
get-vm | where name –like ‘*10’ (PS3.0)
Now just start em up in order, DC, DB, and finally SP, but wait you need to wait before going to the next vm.
So I finally verify for the VM heartbeat before I start another VM.
Here are more optional views
Now lets connect.
Simple VM Connection
So you need to connect to your vm? Just just get a list of vms you want to start. Save as variable and then using vmconnect connect to all in one step.However since this is an array we need to step through each element in our array
Have fun with your VM’s
Stop VM’s
So just as before when we started just get-vm and then pipe to vm-stop. Note that I filtered out just the running vm’sVM Snapshot
So you need to snapshot several VM at one time?No problem, just pipe your vm’s to Checkpoint-vm
Note above that I listed the VM’s and then showed the syntax to verify the snapshots.
Now lets give the snapshots a name just add –snapshotname ‘string’
Now that fun …
Simple Network Configuration
Now I need to connect all the vm’s to a common switch. So let’s look at a new command to show vm network settings. See here that all the vm’s are connected to Private.type Get-vm | Get-VMNetworkAdapter
I need a list of Virtual Switches, here’s how.
type Get-VMSwitch
I need to connect all the VM’s to a Demo Switch, here’s how.
type Get-vm | Get-VMNetworkAdapter | Connect-VMNetworkAdapter –SwitchName ‘Demo’
Now displaying all VM’s attached to Demo
type Get-vm | Get-VMNetworkAdapter | where SwitchName –eq ‘Demo’
VM Settings Administration
Now you need to set a setting for all your vm’s at once, no problem.First list your vm’s, then pipe that list to set-vm. Here is a list of settings, I am going to set the startup memory on all my vm’s with sp in the name.
References:
Hyper-V: Scriptshttp://social.technet.microsoft.com/wiki/contents/articles/176.hyper-v-scripts.aspx
Hyper-V Settings
http://technet.microsoft.com/en-us/library/hh848575(v=wps.620).aspx
Orderly Shutdown from Scripting Guy
http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/21/use-powershell-to-perform-an-orderly-shut-down-of-a-hyper-v-server.aspx
Guide to Hyper-V PowerShell (Technet)
http://technet.microsoft.com/en-us/library/hh848559(v=wps.620).aspx
VM Report Building
http://blog.basefarm.com/blog/2013/01/25/basic-inventory-of-hyperv-virtual-machines-using-powershell/
Virtual Switch
http://technet.microsoft.com/en-us/library/jj679878.aspx
Matching
http://technet.microsoft.com/en-us/library/ee692798.aspx
Kewl Article on Top Ten List on Hyper-v cmdlets
http://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/
MCT Hints
Delete VMs and cleanup from classhttp://cursurimicrosoft.com/index.php/home/delete-all-vm-from-the-previous-moc-course-using-powershell/
Tuesday, April 2, 2013
Monday, January 14, 2013
PowerShell 3.0
Important Command
Update-Help
Installation
http://technet.microsoft.com/en-us/library/hh847837.aspx
Crash Course on V3
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WSV321
Check out what's new in powershell 3.0
http://technet.microsoft.com/en-us/library/hh857339.aspx
Guides from Technet Library
http://technet.microsoft.com/en-us/library/bb978525.aspx
Friday, January 4, 2013
Network Locations using PowerShell
So you can’t manage your network locations from PowerShell by default. Here is a great dll you can add to expose network locations.
Download and extract the dll into your scripts directory from http://archive.msdn.microsoft.com/NLM Look in \NLMCSharp.zip\NLMCSharp\obj\Debug
Add-Type –Path .\Interop.NETWORKLIST.dll
$nlm = new-object NETWORKLIST.NetworkListManagerClass
$nlm.GetNetworks("NLM_ENUM_NETWORK_ALL") | select @{n="Name";e={$_.GetName()}},@{n="Category";e={$_.GetCategory()}},IsConnected,IsConnectedToInternet
Reference from a great article from those scripting guys below
http://blogs.technet.com/b/heyscriptingguy/archive/2012/06/10/weekend-scripter-use-powershell-to-manage-windows-network-locations.aspx