View deleteBuilds.gvy
Jenkins.instance.getItem("projectName").items.each {
it.setDisabled(true)
try {
build = it.getLastBuild()
while (build != null) {
previousBuild = build.previousBuild
View test.linq
<Query Kind="Expression">
<NuGetReference>Newtonsoft.Json</NuGetReference>
<Namespace>Newtonsoft.Json</Namespace>
</Query>
JsonConvert.DeserializeObject("{\"foo\": \"bar\"}")
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