22 February 2023

Powershell - ignoring output performance

 

(Measure-Command -Expression { [void]$(1..100000) }).Milliseconds

53

(Measure-Command -Expression { $null = $(1..100000) }).Milliseconds

49

(Measure-Command -Expression { $(1..100000) > $null }).Milliseconds

62

(Measure-Command -Expression { $(1..100000) | Out-Null }).Milliseconds

393

12 October 2022

Hyper-v - modify maximum simultaneous live migrations / storage migrations

 

Get-SCVMHostCluster | Select-Object -ExpandProperty nodes | Select-Object name | % {Set-VMHost -ComputerName $PSItem.Name -MaximumStorageMigrations 2 -MaximumVirtualMachineMigrations 2 }



Get-SCVMHostCluster | Select-Object -ExpandProperty nodes | Select-Object name | % {Get-VMHost -C\omputerName $PSItem.Name } | Format-Table -AutoSize Name, MaximumStorageMigrations, MaximumVirtualMachineMigrations

19 December 2021

Select-Object splatting

 $PropSplat = @(
    'Name'
    'Status'

    @{
        Name = 'BoolStatus'
        Expression = {
            if($PSItem.Status -eq 'Running'){$false}else{$true}
        }
    }
)

Get-Service m* | Select-Object $PropSplat

17 December 2021

Return line from CSV file (data)

 in order to find and return a specific line from a csv file (data)


$Recepies = Iomport-CSV C:\temp\recepies.scv

$Recepies.Where({$PSItem.Ingredient_1 -eq 'potato'})

30 November 2021

nslookup with arguments

 in order to use nslookup with arguments


nslookup -type=NS microsoft.com

nslookup -type=NS microsoft.com ns1-205.azure-dns.com