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 pippo_1([string]$x) { | |
echo "pippo v1: $x" | |
} | |
function pippo_2([string]$x) { | |
echo "pippo v2: $x" | |
} | |
function pluto_2([string]$x) { | |
echo "pluto v2: $x" |
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
# see https://mcpmag.com/articles/2015/04/15/reporting-on-local-accounts.aspx | |
Function Get-LocalUser { | |
[Cmdletbinding()] | |
Param( | |
[Parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] | |
[String[]]$Computername = $Env:Computername | |
) | |
Begin { |
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
# see https://stackoverflow.com/questions/23239127/powershell-stream-process-output-and-errors-while-running-external-process/28440479 | |
function RunCommand | |
{ | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$True)] | |
[string] $FileName, | |
[Parameter(Mandatory=$True)] | |
[string[]] $Arguments, | |
[string] $OutputPrefix = "> ", |
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
param( | |
[Parameter(Mandatory)] | |
[string] $rootProjectFolder, | |
[Parameter(Mandatory)] | |
[string] $outputGraphFile, | |
[string[]] $excludedProjects = @() | |
) | |
function Get-ProjectReferences |
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
param | |
( | |
[string]$instanceUrl, | |
[string]$PAT, | |
[string]$outputFile = "ReleaseDefinitionInfo.csv" | |
) | |
if ( | |
[string]::IsNullOrEmpty($instanceUrl) -or |
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
RES_GROUP=myRG | |
VM_NAME=gvian-optim-vm | |
# QUERIES TO SEE WHICH VMs NEED TREATMENT | |
# az network nic list --resource-group $RES_GROUP --query "[].[name, enableAcceleratedNetworking]" | |
# az vm list -g $RES_GROUP --query "[].[name, storageProfile.imageReference.publisher, storageProfile.imageReference.sku, hardwareProfile.vmSize, storageProfile.osDisk.caching, storageProfile.dataDisks[*].caching]" | |
# stop VM | |
az vm deallocate -g $RES_GROUP -n $VM_NAME |
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
# az display clearly the version of the image | |
az vm image list --publisher MicrosoftSQLServer --offer SQL2014SP2-WS2012R2 --sku Enterprise --location eastus2 --all | |
# install time of windows package | |
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($(Get-ItemProperty 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion').InstallDate)) | |
# from within an Azure VM | |
Invoke-RestMethod -Headers @{"Metadata"="true"} -URI "http://169.254.169.254/metadata/instance/compute?api-version=2017-04-02" -Method Get | |
# it shows the image version BTW |
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
# Get agent pools (Request method: Get): | |
$uri = "${vstsUrl}/_apis/distributedtask/pools?api-version=${apiVersion}" | |
Write-Host ">>> calling $uri" | |
$allPoolsResult = Invoke-RestMethod -Uri $uri -Method Get @restCallSplat | |
foreach ($poolRec in $allPoolsResult.value) { | |
Write-Host "Processing Agent Pool '$( $poolRec.name )'" | |
# Get agents of an agent pool (Request method: Get): |
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
# run this on the Server (IIS) machine | |
$FQDNs = @("mysite.example","mysite.example.com") | |
$cert = New-SelfSignedCertificate -DnsName $FQDNs -CertStoreLocation "cert:\LocalMachine\My" | |
Write-Host "Created Certificate $($cert.Thumbprint)" | |
Move-Item -Path "cert:\LocalMachine\My\$($cert.Thumbprint)" -Destination "cert:\LocalMachine\WebHosting" |
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
$month = (Get-Date).AddMonths(-1).ToString('yyyy-MM') | |
New-Item -Name $month -ItemType Directory | |
Get-ChildItem | where LastWriteTime -lt "${month}-01" | Move-Item -Destination .\${month} | |
Compress-Archive .\${month}\* -Update -CompressionLevel Optimal -DestinationPath .\${month}.zip | |
Remove-Item $month -Recurse | |
NewerOlder