This file contains hidden or 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
| with sn (tableName, columnName, columnNameUI, max_length, internal_type) as | |
| ( | |
| --See https://docs.servicenow.com/bundle/kingston-application-development/page/integrate/odbc-driver/concept/c_ODBCDrvrSQL20082012.html for info on ODBC driver & setting up a linked server | |
| select name, element, column_label, max_length, internal_type | |
| from openquery(SERVICENOW , ' | |
| select name | |
| , element --database column name | |
| , column_label --UI name | |
| ,CAST(max_length as Decimal(38,0)) max_length --could convert to string here; but this makes it more reusable | |
| ,internal_type |
This file contains hidden or 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
| select cast(stuff(stuff(stuff(stuff('94b01c2b1386ae00a5383927d144b0c0',21,0,'-'),17,0,'-'),13,0,'-'),9,0,'-') as uniqueidentifier) |
This file contains hidden or 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
| #show the current screen buffer size | |
| $Host.UI.RawUI.BufferSize | |
| #update the current screen buffer size | |
| $Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 0) #(width, height) |
This file contains hidden or 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 Start-Computer { #broadcasts a magic packet hoping to invoke the target machine's wake on lan function. NB: uses target computer's mac address rather than name / requires WOL to be enabled, and the device's network card to be listenning to broadcasts on the local subnet | |
| [CmdletBinding()] | |
| Param( | |
| [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
| [ValidateScript({$_ -match '^(?:[^a-fA-F0-9]*[a-fA-F0-9][^a-fA-F0-9]*){12}$'})] #i.e. 12 hex digits (6 pairs) optionaly separated by any non-hex character/string. NB: this does mean 01:01 cannot be written as 1:1, for example. | |
| [string]$MacAddress | |
| , | |
| [Parameter()] | |
| [ValidateSet('IPv4','IPv6')] | |
| [string]$IPVersion = 'IPv4' |
This file contains hidden or 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
| #based on | |
| # - http://blogs.msdn.com/b/heaths/archive/2007/01/31/how-to-safely-delete-orphaned-patches.aspx | |
| # - http://www.bryanvine.com/2015/06/powershell-script-cleaning-up.html | |
| # - https://p0w3rsh3ll.wordpress.com/2012/01/10/working-with-the-windowsinstaller-installer-object/ | |
| clear-host | |
| function Get-WindowsInstallerPatchInfo { | |
| [CmdletBinding()] | |
| Param () |
This file contains hidden or 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
| use AX2012Db_Model | |
| go | |
| select l.Name LayerName | |
| , mm.Name ModelName | |
| , me.Name ElementName | |
| from Model m | |
| inner join Layer l on l.Id = m.LayerId | |
| inner join ModelManifest mm on mm.ModelId = m.Id | |
| inner join ModelElementData med on med.ModelId = m.id |
This file contains hidden or 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
| #value from pipeline | |
| Get-Help 'Get-Process' -Parameter * | ? PipeLineInput -like '*ByValue*' | |
| #value from pipeline by property name | |
| Get-Help 'Get-Process' -Parameter * | ? PipeLineInput -like '*ByPropertyName*' | |
| #see the PSObjects returned by help, instead of the blasphemous "nicely formatted" output | |
| Get-Help 'Get-Process' -Parameter * | select * |
This file contains hidden or 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
| cls | |
| workflow Test-PortOpenQuickly { | |
| [cmdletbinding()] | |
| param( | |
| [Parameter(Mandatory = $true)] | |
| [string]$ComputerName | |
| , | |
| [Parameter(Mandatory = $true)] | |
| [int[]]$Ports | |
| , |
This file contains hidden or 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
| clear-host | |
| $test = @{ | |
| One = 'hi' | |
| Two = @{ | |
| A = 'a' | |
| B = 'b' | |
| } | |
| Three = $null | |
| Four = $false | |
| } |
This file contains hidden or 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-AxQuery { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory = $false)] | |
| $Company | |
| , | |
| [Parameter(Mandatory = $false)] | |
| $Language | |
| , |