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



24 February 2021

Search and install packages from powershellgallery

use this command to modify TLS settings if you get an error running the below commands
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

search for all available package providers
Find-PackageProvider

search for a specific package provider
Find-PackageProvider -name nuget

install a package provider
Install-PackageProvider -Name nuget


after you have a package provider setup you can search for packages

search for a specific package. it supports wildcard in name
Find-Package -Name *AzureAD*

install package
Install-Package -Name AzureAD