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
# Ideally this is [string[]] | |
param([string]$VMNameStr) | |
# Copying from old: Split up names by commas, trim the ends, output to screen | |
$VMNameStr -split "," | %{$_.trim()} |
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
$List = @' | |
1 Partridge in a pear tree | |
2 Turtle Doves | |
3 French Hens | |
4 Calling Birds | |
5 Golden Rings | |
6 Geese a laying | |
7 Swans a swimming | |
8 Maids a milking | |
9 Ladies dancing |
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 Invoke-PowerCSV { | |
[CmdletBinding()] | |
param ( | |
# Position 1 is implied here, and doesn't need to be specified | |
[Parameter(Mandatory = $true)] | |
[string[]]$ComputerName, | |
[Parameter(Mandatory = $true, | |
ValueFromPipeline = $true)] | |
$InputFile, |
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 Get-Uptime { | |
[CmdletBinding()] | |
param ( | |
[Parameter(ValueFromPipeline = $true, | |
ValueFromPipelineByPropertyName = $true)] | |
[string[]]$ComputerName = $env:COMPUTERNAME | |
) | |
BEGIN { | |
# Define $Results array to append each computer into; get the current date once |
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 Get-Diacritic { | |
<# | |
.SYNOPSIS | |
Find filenames with diacritic marks, export the list to CSV, and email the list to your boss. | |
.LINK | |
http://powershell.org/wp/2016/03/05/2016-march-scripting-games-puzzle/ | |
#> | |
[CmdletBinding()] | |
param ( |
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
<#PSScriptInfo | |
.VERSION 1.0 | |
.GUID a9323abc-0567-4c4f-ad8e-cdd4cb236e3a | |
.AUTHOR Brian | |
.COMPANYNAME |
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
$Splatting = @{ | |
Path = "$env:USERPROFILE\Desktop\Your-Script.ps1" | |
Version = '1.0.0' # http://semver.org ;) | |
# GUID will randomly auto-generate for new scripts | |
# Only specify GUID if you're going to overwrite existing properties on an updated script version | |
Author = 'YourPSGalleryUsername' | |
Description = 'Explain your script to prospective users, preferably in one sentence.' | |
# CompanyName | |
# Copyright | |
Tags = @('super','awesome','radical') |
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
# This code doesn't work. :) Soliciting feedback | |
# Just started duplicating info from here: | |
# (Get-VM 'ExampleVM') | gm | Where MemberType -eq 'Property' | Select Name,Definition | |
$r = "c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Sdk\VMware.VimAutomation.Sdk.Types.dll", | |
"c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.VimAutomation.ViCore.Types.dll" | |
Add-Type -ReferencedAssemblies $r -TypeDefinition " | |
using VMware.VimAutomation.ViCore.Types.V1; |
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
# Barely working :D | |
# Follows my previous Gist, https://gist.github.com/brianbunke/13e32ae67a9232d2224601e937eebba7 | |
# http://theshellnut.com/exploring-powercli-types/ | |
# http://stackoverflow.com/questions/14141043/resolving-an-ambiguous-reference | |
ipmo VMware.VimAutomation.Core | |
$r = "c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Sdk\VMware.VimAutomation.Sdk.Types.dll", | |
"c:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.VimAutomation.ViCore.Types.dll", |
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
#Requires -Version 3 | |
Import-Module VMware.VimAutomation.Core | |
Connect-VIServer XXXXX | |
$Report = New-Object 'System.Collections.Generic.List[PSCustomObject]' | |
$VM = Get-VM | |
$VM | ForEach-Object { | |
$Obj = [PSCustomObject][ordered]@{ | |
VMName = $_.Name |
OlderNewer