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
Register-ArgumentCompleter -ParameterName ComputerName -ScriptBlock { | |
param( | |
$commandName, | |
$parameterName, | |
$wordToComplete, | |
$commandAst, | |
$fakeBoundParameter | |
) | |
$record = [System.Net.Dns]::Resolve($wordToComplete) | |
if ($record) { |
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
#region Basics... | |
# implicit foreach on Adapted Type System object. | |
$xml = [xml]@' | |
<node attribute="attributeValue"> | |
<CaseSensitive>First</CaseSensitive> | |
<caseSensitive>second</caseSensitive> | |
</node> | |
'@ | |
$PSDefaultParameterValues.'Select-Xml:Xml' = $xml |
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
netsh dhcp server scope 192.168.7.0 show clients 1 | % { | |
if ($_ -match '(?n)(?<ip>\S+).*?(?<mac>([0-9a-f]{2}-){5}[0-9a-f]{2}).*?(?<name>\b\w+\.monad\.net)') { | |
$Matches.Remove(0) | |
$Matches.mac = $Matches.mac -replace '-', ':' | |
[PSCustomOBject]$Matches | |
} | |
} |
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
<# | |
Assumptions: | |
-- uses v3 module manifest (RootModule rather than ModuleToProcess) | |
-- RootModule contains name of the file only | |
-- Certain pattern can be used to check only functions that follow naming convention (here: *-Cim*) | |
Also: | |
-- Actual tests include more actions related to manifest contents, thus "context" block is used | |
-- Actual test is testing multiple modules/ manifests, thus $manifest in the real scenario is part of foreach ($manifest in ls) {} | |
#> |
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 Search-AD { | |
<# | |
.Synopsis | |
Function to search Active Directory using specified filter. | |
.Description | |
Function uses selected LDAP filter to search Active Directory. | |
It doesn't have any external dependencies and is using ADSISearcher class. | |
User can specify attributes that should be retrieved and SearchRoot. |
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 taken from SO answer: | |
http://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value | |
#> | |
$ExCellStyles = @{ | |
0 = 'General' | |
1 = '0' | |
2 = '0.00' | |
3 = '#,##0' |
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
$data = @' | |
= | |
Adam Nowacki | |
Domowy:123 456 789 | |
Praca:999 999 999 | |
[prywatny/[email protected]] | |
[sluzbowy/[email protected]] | |
= | |
Anna Kowalska | |
Domowy:123 456 789 |
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
$Template = @' | |
{Name*:霧嶋 董香} | |
{City:Redmond}, {State:WA} | |
{Name*:Łukasz Ćwikalski} | |
{City:ワルシャワ}, {State:PL} | |
'@ | |
$Data = @' | |
霧嶋 董香 |
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
configuration LinuxDscDemo { | |
param ( | |
[string]$ComputerName | |
) | |
Import-DscResource -Module nx | |
Node $ComputerName { | |
nxUser LinuxDsc { |
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
$Common = @{ | |
Path = 'SomeTables.xhtml' | |
Namespace = @{ | |
d = 'http://www.w3.org/1999/xhtml' | |
} | |
} | |
Select-Xml -XPath '//d:table[d:tr[@class]]' @Common | | |
ForEach-Object { $_.Node } | Format-Table -AutoSize |