Skip to content

Instantly share code, notes, and snippets.

Get-VMHost | Select Name,Model, `
@{Name = "Hostname";Expression = {$_.NetworkInfo.Hostname}}, `
@{Name = "Cluster";Expression = {$_.Parent.Name}}, `
@{Name = "ServiceTag";Expression = {((get-view -ViewType HostSystem -Filter @{"Name" = $_.Name} -Property "Summary.Hardware.OtherIdentifyingInfo").Summary.Hardware.OtherIdentifyingInfo | ? { $_.IdentifierType.key -eq 'ServiceTag' }).IdentifierValue}}

Git Primer

Attempt to dumb down most commonly needed git tasks.

Generic workflow for adding code

# initial download of the repo, get link from the green "Clone or download" button on github
git clone [url]
function Invoke-ScriptAsync {
[cmdletbinding()]
param(
#Script block to execute
[Parameter(Mandatory)]
[ScriptBlock] $ScriptBlock,
#Array of argument lists or parameter hashes for the script block
Param (
[Parameter(Mandatory = $false, Position = 0)]
[string]$ComputerName = 'localhost',
[Parameter(Mandatory = $false, Position = 1)]
[string]$OutputPath,
[Parameter(ParameterSetName = "Credential", Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
to remove old licenses: /usr/local/Enterasys_Networks/NetSight/appdata/license
# got from http://mspowershell.blogspot.co.uk/2009/02/cli-menu-in-powershell.html?m=1
function DrawMenu {
## supportfunction to the Menu function below
param ($menuItems, $menuPosition, $menuTitel)
$fcolor = "Red"
$bcolor = "Black"
$l = $menuItems.length + 1
cls
$menuwidth = $menuTitel.length + 4
# Changes the terminal profile from one setting to another when entering and exiting powershell.
# would be cool to add the ability to read the current profile when starting powershell so you can change back without manually defining it.
osascript -e 'tell application \"Terminal\" to set current settings of selected tab of front window to settings set \"Solarized PS\"'
Register-EngineEvent powershell.exiting -action { osascript -e 'tell application \"Terminal\" to set current settings of selected tab of front window to settings set \"Solarized Dark\"' -SupportEvent }
param
(
[System.Management.Automation.CredentialAttribute()]
$Credential
)
###############################################################################
#
# iSCSI Fixer
# Q1 2014
# brian.addicks@lockstepgroup.com
#
###############################################################################
#
$DiscoveryPortals = @("192.168.99.19"
ipmo dhcpserver
$DhcpServer = Read-Host "Dhcp Server?"
$Scopes = Get-DhcpServerv4Scope -ComputerName $DhcpServer
$ServerOptions = Get-DhcpServerv4OptionValue -ComputerName $DhcpServer
foreach ($s in $Scopes) {
foreach ($o in $ServerOptions) {
Set-DhcpServerv4OptionValue -OptionId $o.OptionId -Value $o.Value -ScopeId $s.ScopeId -ComputerName $DhcpServer
}
}