# vNiklas DemoTime for SC SP1 SpringMeeting # # Niklas Åkerlund/ 20130404 #region VMM Module initiation Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force Import-Module virtualmachinemanager #endregion #region Get-VMM Commands Get-Command -Module virtualmachinemanager (Get-Command -Module virtualmachinemanager).Count Get-Help Get-SCVirtualMachine -full Update-Help -Module virtualmachinemanager #endregion #region Get-VM Info # Get VM Integration version Get-SCVirtualMachine | Select Name,VMAddition,Status | Sort-Object Status | ft -AutoSize #endregion #region Configure Get-SCVirtualMachine vmtest | Stop-SCVirtualMachine | Set-SCVirtualMachine -CPUCount 2 | Start-SCVirtualMachine #endregion #region Remove ISO´s from VM´s Get-SCVirtualMachine -VMHost HV03 | Get-SCVirtualDVDDrive | Set-SCVirtualDVDDrive -NoMedia #endregion #region Out-GridView Get-SCVirtualMachine | Select Name,VMAddition,Location | Out-GridView #endregion #region CustomProps New-SCCustomProperty -Name "DynamicVHD" -AddMember "VM" New-SCCustomProperty -Name "Snapshots" -AddMember "VM" New-SCCustomProperty -Name "Datastore" -AddMember "VM" C:\PowerShell\UpdateCustomProps.ps1 #endregion #region Scheduling Get-command -Module *PSsch* $once = New-JobTrigger -Once -At 01:35PM Register-ScheduledJob -Name AddvCPU2 -ScriptBlock {Get-SCVirtualMachine vmtest | Stop-SCVirtualMachine | Set-SCVirtualMachine -CPUCount 2 | Start-SCVirtualMachine} -Trigger $once Import-Module PSScheduledJob Get-ScheduledJob | Remove-JobTrigger Get-ScheduledJob | Unregister-ScheduledJob Get-Job | Remove-Job #endregion #region backup vmm # If not using any other database backup then schedule this-> Backup-SCVMMServer -Path c:\temp\ #endregion #region Webaccess Get-WindowsFeature WindowsPowerShellWebAccess | Add-WindowsFeature Install-PswaWebApplication -UseTestCertificate Add-PswaAuthorizationRule * * * #endregion #region Tips/urls #Powershell Crash Course http://technet.microsoft.com/en-us/magazine/hh551144.aspx http://www.windowsazure.com/en-us/manage/services/networking/active-directory-forest/ http://msdn.microsoft.com/en-us/library/windowsazure/jj152841.aspx http://technet.microsoft.com/en-us/library/hh847890.aspx http://michaelwasham.com/ http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/21/understanding-the-six-powershell-profiles.aspx http://blog.aswinboy.net/?p=383 #endregion