This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Added from http://bretty.me.uk/save-money-using-citrix-octoblu-automation-for-power-management/ | |
# Author: Dave Brett | |
function Lab-Shutdown { | |
$ErrorActionPreference = 'Continue' | |
import-module XenServerPSModule | |
connect-xenserver -url http://xs.bretty.local -username USERNAME -password PASSWORD | |
$file = "c:\Scripts\vmlist.txt" | |
$VMNames = Get-Content $file | |
foreach($VMName in $VMNames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vmListFilePath = "c:\Scripts\vmlist.txt" | |
. c:\scripts\Set-LabPowerState.ps1 | |
if (Test-Path -Path "$vmListFilePath") | |
{ | |
$setLabPower = @{ | |
Credential = Import-Clixml -Path "c:\scripts\XenCred.xml" | |
XenServerUrl = "http://xs.bretty.local" | |
Shutdown = $true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-LabPowerstate | |
{ | |
<# | |
.Synopsis | |
Sets powermode for VMs on XenServer | |
.DESCRIPTION | |
This can shutdown or restart a VM or a collection of VMs. The function supports WhatIf. The XenServerPSModule | |
and vaild credentials on the XenServer is required to run this function. This function supports pipelineinput | |
for the VMname parameter. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cred = Import-CliXml -Path c:\scripts\XenCred.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cred = Get-Credential | |
Export-Clixml -Path c:\temp\XenCred.xml -Depth 3 -InputObject $cred | |
# Or as one line: | |
Get-Credential | Export-Clixml -Path c:\temp\XenCred.xml -Depth 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-String | |
{ | |
param( | |
[parameter(Valuefrompipeline)] | |
[string]$InputObject | |
) | |
Begin | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Source = @” | |
using System; | |
namespace ArrayTest | |
{ | |
public static class ArrayStuff | |
{ | |
public static sample ForEach(System.Array _items, int[] Id) | |
{ | |
foreach (sample item in _items) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach($count in (0..10)) | |
{ | |
$id1 = $CollectionOfIDs | Get-Random | |
$id2 = $CollectionOfIDs | Get-Random | |
[gc]::Collect() | |
$measureHash += Measure-Command -Expression { | |
$csvHash[$id1,$id2] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$csvHash = @{} | |
foreach($obj in $csvObjects) | |
{ | |
$csvHash[$obj.id] = $obj | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$measureWhere = @() | |
foreach ($count in (0..10)) | |
{ | |
$id1 = $CollectionOfIDs | Get-Random | |
$id2 = $CollectionOfIDs | Get-Random | |
[gc]::Collect() | |
$measureWhere += Measure-Command -Expression { | |
$csvObjects.Where({$_.id -eq $id1 -or $_.id -eq $id2}) | |
} | |
} |