View jsonnet-separation.xml
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<codeBase version="10.0.0.0" href="bin/Newtonsoft.Json.10.0.0.0/Newtonsoft.Json.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
View Progress-Sample.ps1
for ($stage = 0; $stage -lt 10; ++$stage) {
for ($step = 0; $step -lt 10; ++$step) {
Write-Progress `
-Activity 'インストール中' `
-Status "ステージ $stage" `
-CurrentOperation "ステップ $step" `
-PercentComplete ($stage * 10 + $step) `
-Id 0
View add-function.ps1
function Show-Hoge {
Write-Host 'Hoge'
}
$func = ${function:Show-Hoge}
Invoke-Command -Session $session -ScriptBlock {
New-Item -Path 'Function:\Show-Hoge' -Value $using:func > $null
Show-Hoge
}
View Find-UpdatedModule.ps1
$module = Get-Module -ListAvailable
# $module = Get-InstalledModule
$module |
Select-Object -Property 'Name', 'Version' |
Group-Object -Property 'Name' |
ForEach-Object -PipelineVariable 'm' {
$_.Group |
Sort-Object -Property 'Version' -Descending |
Select-Object -First 1
View Uninstall-OldModule.ps1
function Uninstall-OldModule {
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High')]
param(
[string] $Name,
[switch] $Force)
View Ssh.txt
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Ssh
Proxy
@completion-port-threads
@ip4-bind-port
@ip6-bind-port
@listeners
@session-pipe-prefix
@session-app-name
@session-pipe-timeout
@session-timeout
View common-parameters.ps1
function Get-CommonParameter {
[OutputType([Hashtable])]
[CmdletBinding(
SupportsShouldProcess)]
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSShouldProcess', '')]
param(
View query1.ps1
# This query is valid. __InstanceCreationEvent class has TargetInstance property.
$query = @'
SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe'
'@
$evt = Register-CimIndicationEvent -Query $query -SourceIdentifier 'TestEvent' -Action {
$EventArgs | Get-Member -Force | Out-Default
$EventArgs | Format-List * | Out-Default
$e = $EventArgs.NewEvent
View coffee.cs
case (order)
{
case "Small Coffee":
return 5.0;
case "Small Coffee. please.":
return 3.0;
case "Hello, one small coffee please.":
return 1.75;
View New-Date.ps1
<#
.Synopsis
新規にDatetime型のオブジェクトを生成します。
.DESCRIPTION
新規にDatetime型のオブジェクトを生成します。
Get-Dateとは異なり現在時刻を基準とせず、未指定のパラメーターには初期値を割り当ててオブジェクトを生成します。
.OUTPUTS
Format パラメーターまたは UFormat パラメーターを使用した場合、Get-Date は文字列を返します。それ以外の場合は、DateTime オブジェクトが返されます。
.EXAMPLE
New-Date -Year 2016 -Month 3 -Day 7