Skip to content

Instantly share code, notes, and snippets.

@barbeque
Created March 12, 2015 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbeque/44a00a1bbaa02509b961 to your computer and use it in GitHub Desktop.
Save barbeque/44a00a1bbaa02509b961 to your computer and use it in GitHub Desktop.
Defining custom object and passing it into powershell functions
function NewSteak() {
$steak = New-Object PSObject
$steak | Add-Member -type NoteProperty -Name Doneness -Value "Rare"
$steak | Add-Member -type NoteProperty -Name Juiciness -Value "Low"
return $steak
}
function AuditSteak([PSObject]$steak) {
Write-Host "The steak is" $steak.Doneness
}
$steak = NewSteak
AuditSteak($steak)
@scanbix
Copy link

scanbix commented Feb 26, 2021

This is an old way to create object

@iloving
Copy link

iloving commented Jun 1, 2021

If that's the 'old' way, what is the new way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment