conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add Windows Power Shell script example that counts the number of Windows handles allocated to all processes\n" }, { "from": "gpt", "value": "<#\n\n.SYNOPSIS\n\nRetrieves the sum of handles (GDI Objects, Kernel Objects, etc) from all the\nprocesses running on the Windows host.\n\n.EXAMPLE\n\nPS > Get-Handles\nGets the total number of handles\n\n.EXAMPLE\n\nPS > Get-DiskUsage -IncludeSubdirectories\nGets the disk usage for the current directory and those below it,\nadding the size of child directories to the directory that contains them.\n\n#>\n\n# Initialize our count of the number of handles\n$handleCount = 0\n\n# Loop through each process, get the number of handles, compute the sum\nforeach($process in Get-Process) { $handleCount += $process.Handles }\n\n# Get the source of the metric in this case the host\n$source = hostname\n\n# Output the metric, standard out??\n\"BOUNDARY_WINDOWS_HANDLES $handleCount $source\"\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix for epmty path and absolute paths\n\nIf a path is empty \"Get-TrimedPath\" will return \".\\\"\nAdded logic to get absolute paths working\n" }, { "from": "human", "value": "function Get-TrimedPath\n{\n param (\n [String] [Parameter(Mandatory = $true)]\n $Path = \"\"\n)\n\n Write-Verbose \"Entering Method Get-TrimedPath\"\n\n $Path = $Path.Trim().Trim(\"\"\"\").Trim().Replace(\"/\",\"\\\\\").Trim(\"\\\")\n if($Path -ne \"\")\n {\n $Path = \".\\\" + $Path + \"\\\"\n }\n else\n {\n $Path = \".\\\"\n }\n\n Write-Verbose \"Leaving script Get-TrimedPath\"\n\n return $Path\n}" }, { "from": "gpt", "value": "function Get-TrimedPath\n{\n param (\n [String] [Parameter(Mandatory = $false)]\n $Path = \"\"\n)\n\n Write-Verbose \"Entering Method Get-TrimedPath\"\n\n $Path = $Path.Trim().Trim(\"\"\"\").Trim().Replace(\"/\",\"\\\\\").Trim(\"\\\")\n if($Path -ne \"\")\n {\n if(-not [System.IO.Path]::IsPathRooted($Path))\n {\n $Path = \".\\\" + $Path + \"\\\"\n }\n else\n {\n $Path = $Path + \"\\\"\n }\n }\n else\n {\n $Path = \".\\\"\n }\n\n Write-Verbose \"Leaving script Get-TrimedPath\"\n\n return $Path\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Fix CI zip creation to include Nether.Web.xml\n" }, { "from": "human", "value": "$netherRoot = $PSScriptRoot\n\ndotnet publish \"$netherRoot/src/Nether.Web\" -c Release\n[Reflection.Assembly]::LoadWithPartialName( \"System.IO.Compression.FileSystem\" ) | out-null\n[System.IO.Compression.ZipFile]::CreateFromDirectory(\"$netherRoot/src/Nether.Web/bin/Release/netcoreapp1.1/publish\", \"$netherRoot/src/Nether.Web/bin/Release/netcoreapp1.1/Nether.Web.zip\", \"Fastest\", $false)\n" }, { "from": "gpt", "value": "$netherRoot = $PSScriptRoot\n\ndotnet publish \"$netherRoot/src/Nether.Web\" -c Release\nCopy-Item \"$publishPath/../Nether.Web.xml\" $publishPath\n\n[Reflection.Assembly]::LoadWithPartialName( \"System.IO.Compression.FileSystem\" ) | out-null\n[System.IO.Compression.ZipFile]::CreateFromDirectory(\"$netherRoot/src/Nether.Web/bin/Release/netcoreapp1.1/publish\", \"$netherRoot/src/Nether.Web/bin/Release/netcoreapp1.1/Nether.Web.zip\", \"Fastest\", $false)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Allow the build number to be passed in and added to the version number.\n" }, { "from": "human", "value": "#\r\n# Simple script to build the nuget package\r\n# when run from the continuous integration server. The result\r\n# of this guy will be become a build artifact.\r\n#\r\n\r\n\r\n$mod = Resolve-Path .\\LINQToTTree\\BuildScripts\\BuildUtils.psm1\r\n$policy = Get-ExecutionPolicy\r\nImport-Module $mod\r\n\r\n#\r\n# Some config - which might oneday be passed in as arguments!\r\n#\r\n\r\n$release = \"x86\\Release\"\r\n$NameSuffix = \"-ci\"\r\n\r\n#\r\n# The CI builder has already done all the hard work for us, so we need to just go\r\n# and get everything.\r\n#\r\n\r\n# First, we need to put together the version number that we will use to register\r\n# this nuget package\r\n\r\n$FileVersion = (Get-Item \"LINQToTTree\\LINQToTTreeLib\\bin\\$release\\LINQToTTreeLib.dll\").VersionInfo.ProductVersion\r\n$version = $FileVersion\r\n\r\n# Next, do the nuget build!\r\n\r\n#-nugetDistroDirectory $nugetPackageDir \r\n$currentPath = Resolve-Path \".\"\r\nbuild-LINQToTTree-nuget-packages $currentPath $currentPath $version -PDB:$PDB -NameSuffix $NameSuffix -Release $release\r\n" }, { "from": "gpt", "value": "#\r\n# Simple script to build the nuget package\r\n# when run from the continuous integration server. The result\r\n# of this guy will be become a build artifact.\r\n#\r\nparam([int] $BuildNumber = 0)\r\n\r\n$mod = Resolve-Path .\\LINQToTTree\\BuildScripts\\BuildUtils.psm1\r\n$policy = Get-ExecutionPolicy\r\nImport-Module $mod\r\n\r\n#\r\n# Some config - which might oneday be passed in as arguments!\r\n#\r\n\r\n$release = \"x86\\Release\"\r\n$NameSuffix = \"-ci\"\r\n\r\n#\r\n# The CI builder has already done all the hard work for us, so we need to just go\r\n# and get everything.\r\n#\r\n\r\n# First, we need to put together the version number that we will use to register\r\n# this nuget package\r\n\r\n$FileVersion = (Get-Item \"LINQToTTree\\LINQToTTreeLib\\bin\\$release\\LINQToTTreeLib.dll\").VersionInfo.ProductVersion -split \"\\.\"\r\n$FileVersion[3] = $BuildNumber\r\n$version = $FileVersion -join \".\"\r\n\r\n# Next, do the nuget build!\r\n\r\n#-nugetDistroDirectory $nugetPackageDir \r\n$currentPath = Resolve-Path \".\"\r\nbuild-LINQToTTree-nuget-packages $currentPath $currentPath $version -PDB:$PDB -NameSuffix $NameSuffix -Release $release\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "GEODE-4988: Install .NET 3.5 for Nunit.\n" }, { "from": "human", "value": "choco install jdk8 -confirm\nchoco install cmake.portable -confirm\nchoco install git.install -confirm\nchoco install activeperl -confirm\nchoco install doxygen.install --allowEmptyChecksums -confirm\nchoco install nunit.install --version 2.6.4 -confirm\nchoco install netfx-4.5.2-devpack --allowEmptyChecksums -confirm\nchoco install nsis -confirm\nchoco install patch -confirm\nchoco install gnuwin32-coreutils.portable -confirm\nchoco install nuget.commandline -confirm\n" }, { "from": "gpt", "value": "choco install jdk8 -confirm\nchoco install cmake.portable -confirm\nchoco install git.install -confirm\nchoco install activeperl -confirm\nchoco install doxygen.install --allowEmptyChecksums -confirm\nchoco install dogtail.dotnet3.5sp1\nchoco install nunit.install --version 2.6.4 -confirm\nchoco install netfx-4.5.2-devpack --allowEmptyChecksums -confirm\nchoco install nsis -confirm\nchoco install patch -confirm\nchoco install gnuwin32-coreutils.portable -confirm\nchoco install nuget.commandline -confirm\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add easy button for Angular setup\n\n" }, { "from": "gpt", "value": "### Install and configure some handy tools for building Angular applications\n### Run this script from an administrative shell\n\nSet-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass\n\nWrite-Output \"\"\nWrite-Output \"Installing Chocolatey package manager\"\nInvoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\nRefreshEnv.cmd\n\nWrite-Output \"\"\nWrite-Output \"Installing NodeJS JavaScript runtime\"\nchoco install -y nodejs-lts\nRefreshEnv.cmd\n\nWrite-Output \"\"\nWrite-Output \"Installing Visual Studio Code editor\"\nchoco install -y visualstudiocode\nRefreshEnv.cmd\n\nWrite-Output \"\"\nWrite-Output \"Installing VS Code extensions for Angular development\"\ncode --install-extension johnpapa.angular-essentials\n\nWrite-Output \"\"\nWrite-Output \"Installing the Angular command line interface\"\nnpm install -g @angular/cli\n" } ]
powershell
chosen
[ { "from": "system", "value": "Clean Target directories before running tests\n\n" }, { "from": "human", "value": "If ($args.Length -ne 0)\n{\n\t$env:NeoctrlArgs=\"$args\"\n\techo $Env:NeoctrlArgs\n}\n$scriptpath = $MyInvocation.MyCommand.Path\n$dir = Split-Path $scriptpath\n\nInvoke-Expression \"cd $dir\\Neo4j.Driver.Tests; dotnet xunit -f net452 -nobuild\"\nInvoke-Expression \"cd $dir\\Neo4j.Driver.IntegrationTests; dotnet xunit -f net452 -nobuild -parallel none\"\nInvoke-Expression \"cd $dir\\Neo4j.Driver.Tck.Tests; dotnet xunit -f net452 -nobuild -parallel none\"\n\n" }, { "from": "gpt", "value": "If ($args.Length -ne 0)\n{\n\t$env:NeoctrlArgs=\"$args\"\n\techo $Env:NeoctrlArgs\n}\n$scriptpath = $MyInvocation.MyCommand.Path\n$dir = Split-Path $scriptpath\n\nIf (Test-Path $dir\\Target) {\n\tRemove-Item -Path $dir\\Target -Recurse -Force\t\n}\n\nIf (Test-Path $dir\\..\\Target) {\n\tRemove-Item -Path $dir\\..\\Target -Recurse -Force\t\n}\n\nInvoke-Expression \"cd $dir\\Neo4j.Driver.Tests; dotnet xunit -f net452 -nobuild\"\nInvoke-Expression \"cd $dir\\Neo4j.Driver.IntegrationTests; dotnet xunit -f net452 -nobuild -parallel none\"\nInvoke-Expression \"cd $dir\\Neo4j.Driver.Tck.Tests; dotnet xunit -f net452 -nobuild -parallel none\"\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add verbose logging to vso package script\n" }, { "from": "human", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i'\n\ncp package.json src/\n\ncd src/\n\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i --production'\n\ncd ..\n\nif (test-path $zipPath) {\n rm $zipPath\n}\n\nZipFiles $zipPath src/\n" }, { "from": "gpt", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\n\necho \"Installing base npm modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i'\n\necho \"Moving package.json\"\ncp package.json src/\n\necho \"Moving into src/\"\ncd src/\n\necho \"Installing base production modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i --production'\n\necho \"Moving out of src/\"\ncd ..\n\nif (test-path $zipPath) {\n echo \"Deleting old zip\"\n rm $zipPath\n}\n\necho \"Creating new zip\"\nZipFiles $zipPath src/\n" } ]
powershell
chosen
[ { "from": "system", "value": "Set RUSTFLAGS to use static CRT in MSI test script\n" }, { "from": "human", "value": "# This script can be used for manually testing the MSI installer. It is not used for AppVeyor CI.\n\npushd ..\\..\\..\n# Build rustup.exe\ncargo build --release --target i686-pc-windows-msvc --features msi-installed\npopd\nif($LastExitCode -ne 0) { exit $LastExitCode }\npushd ..\n# Build the CA library\ncargo build --release --target i686-pc-windows-msvc\npopd\nif($LastExitCode -ne 0) { exit $LastExitCode }\n# Build the MSI\n.\\build.ps1 -Target i686-pc-windows-msvc\nif($LastExitCode -ne 0) { exit $LastExitCode }\n# Run the MSI with logging\n$OLD_CARGO_HOME = $env:CARGO_HOME\n$OLD_RUSTUP_HOME = $env:RUSTUP_HOME\n$env:CARGO_HOME = \"$env:USERPROFILE\\.cargo-test\"\n$env:RUSTUP_HOME = \"$env:USERPROFILE\\.rustup-test\"\nStart-Process msiexec -ArgumentList \"/i target\\rustup.msi /L*V target\\Install.log\" -Wait\n$env:CARGO_HOME = $OLD_CARGO_HOME\n$env:RUSTUP_HOME = $OLD_RUSTUP_HOME" }, { "from": "gpt", "value": "# This script can be used for manually testing the MSI installer. It is not used for AppVeyor CI.\n\n$env:RUSTFLAGS=\"-Zunstable-options -Ctarget-feature=+crt-static\"\n\npushd ..\\..\\..\n# Build rustup.exe\ncargo build --release --target i686-pc-windows-msvc --features msi-installed\npopd\nif($LastExitCode -ne 0) { exit $LastExitCode }\npushd ..\n# Build the CA library\ncargo build --release --target i686-pc-windows-msvc\npopd\nif($LastExitCode -ne 0) { exit $LastExitCode }\n# Build the MSI\n.\\build.ps1 -Target i686-pc-windows-msvc\nif($LastExitCode -ne 0) { exit $LastExitCode }\n# Run the MSI with logging\n$OLD_CARGO_HOME = $env:CARGO_HOME\n$OLD_RUSTUP_HOME = $env:RUSTUP_HOME\n$env:CARGO_HOME = \"$env:USERPROFILE\\.cargo-test\"\n$env:RUSTUP_HOME = \"$env:USERPROFILE\\.rustup-test\"\nStart-Process msiexec -ArgumentList \"/i target\\rustup.msi /L*V target\\Install.log\" -Wait\n$env:CARGO_HOME = $OLD_CARGO_HOME\n$env:RUSTUP_HOME = $OLD_RUSTUP_HOME" } ]
powershell
chosen
[ { "from": "human", "value": "Add sample script to configure IIS\n" }, { "from": "gpt", "value": "Import-Module WebAdministration\n\n$appPoolName = \"AppPoolName\";\n\n$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Path -Parent;\n\n$sourceRoot = Split-Path -Path (Split-Path -Path $MyInvocation.MyCommand.Path -Parent) -Parent;\n\nfunction Install-Site ([string]$siteName, [string]$relPath, [string]$hostname, [int]$id)\n{\n\t$fullPath = Join-Path $sourceRoot $relPath\t\n\t\n\t# Allow NetworkService to access the directory\n\tSet-Permissions $fullPath\n\t\n\t# Create the website for the app\n\tNew-Website -Name $siteName -Id $id -ApplicationPool $appPoolName -PhysicalPath $fullPath -HostHeader $hostname\n\t\n\tSet-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name username -value \"\" -location $siteName\n\t\n\t# Adds the hostname entry in the hosts file for DNS resolution\n\tAdd-Content C:\\Windows\\System32\\drivers\\etc\\hosts \"127.0.0.1 $hostname\";\n}\n\nfunction Set-Permissions($path)\n{\n\t$acl = Get-Acl $path\n\t\n\t$acl.SetAccessRuleProtection($True, $True);\n\t\n\t$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(\"IIS AppPool\\$appPoolName\", \"Read\", \"ContainerInherit, ObjectInherit\", \"None\", \"Allow\");\n \n\t$acl.AddAccessRule($rule);\n\t\n\tSet-Acl $path $acl;\n}\n\n# Setup AppPool\n$appPool = New-WebAppPool -Name $appPoolName;\n$appPool.managedRuntimeVersion = \"v4.0\";\n$appPool | Set-Item;\n\n# Setup IIS Websites and Projects\n\nInstall-Site \"WebSite\" \"Web Applications\\WebSiteCodeGoesHere\" 'website.local' 101\n\nWrite-Host \"You will need to add 'IIS AppPool\\$appPoolName' to your SQL Server instance with access to the correct database\"" } ]
powershell
chosen
[ { "from": "system", "value": "Upgrade to VM version 7.0.36\n" }, { "from": "human", "value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.35\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion" }, { "from": "gpt", "value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.36\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion" } ]
powershell
chosen
[ { "from": "system", "value": "Change path on android sdk installer script\n" }, { "from": "human", "value": "#$AndroidToolPath = \"${env:ProgramFiles(x86)}\\Android\\android-sdk\\tools\\android\" \n$AndroidToolPath = \"$env:localappdata\\Android\\android-sdk\\tools\\android\"\n\nFunction Get-AndroidSDKs() { \n $output = & $AndroidToolPath list sdk --all \n $sdks = $output |% { \n if ($_ -match '(?<index>\\d+)- (?<sdk>.+), revision (?<revision>[\\d\\.]+)') { \n $sdk = New-Object PSObject \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision \n $sdk \n } \n } \n $sdks \n}\n\nFunction Install-AndroidSDK() { \n [CmdletBinding()] \n Param( \n [Parameter(Mandatory=$true, Position=0)] \n [PSObject[]]$sdks \n )\n\n $sdkIndexes = $sdks |% { $_.Index } \n $sdkIndexArgument = [string]::Join(',', $sdkIndexes) \n Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument \n}\n\n$sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 10*' -or $_.name -like 'google apis*api 10' } \nInstall-AndroidSDK -sdks $sdks\n" }, { "from": "gpt", "value": "$AndroidToolPath = \"${env:ProgramFiles(x86)}\\Android\\android-sdk\\tools\\android\" \n#$AndroidToolPath = \"$env:localappdata\\Android\\android-sdk\\tools\\android\"\n\nFunction Get-AndroidSDKs() { \n $output = & $AndroidToolPath list sdk --all \n $sdks = $output |% { \n if ($_ -match '(?<index>\\d+)- (?<sdk>.+), revision (?<revision>[\\d\\.]+)') { \n $sdk = New-Object PSObject \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision \n $sdk \n } \n } \n $sdks \n}\n\nFunction Install-AndroidSDK() { \n [CmdletBinding()] \n Param( \n [Parameter(Mandatory=$true, Position=0)] \n [PSObject[]]$sdks \n )\n\n $sdkIndexes = $sdks |% { $_.Index } \n $sdkIndexArgument = [string]::Join(',', $sdkIndexes) \n Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument \n}\n\n$sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 10*' -or $_.name -like 'google apis*api 10' } \nInstall-AndroidSDK -sdks $sdks\n" } ]
powershell
chosen
[ { "from": "system", "value": "Switch packaging script to PowerShell.\n" }, { "from": "human", "value": "@ECHO OFF\nREM ---------------------------------------------------------------------------\nREM Builds the file utility nuget packages.\nREM ---------------------------------------------------------------------------\n\nSETLOCAL\n\nSET BUILD_NUMBER=%1\nIF \"%BUILD_NUMBER%\" == \"\" SET BUILD_NUMBER=5555\nECHO BUILD_NUMBER=%BUILD_NUMBER%\n\nSET /p VERSION=<ver.platform.txt\n\nECHO Making packages for %VERSION%.%BUILD_NUMBER%\n\nSET PACKCMD=dotnet pack -c Release /p:Version=%VERSION%\nECHO PACKCMD=%PACKCMD%\n\nSET PROJECTS=SoundMetrics.Aris.Comms SoundMetrics.Aris.Config SoundMetrics.Aris.FrameHeaderInjection\nSET PROJECTS=%PROJECTS% SoundMetrics.Aris.Messages SoundMetrics.Aris.ReorderCS SoundMetrics.NativeMemory\n\nFOR %%p in (%PROJECTS%) do (\n ECHO ---------------------------------------------------------------------\n ECHO %%p\n ECHO ---------------------------------------------------------------------\n %PACKCMD% %%p\n)\n\nENDLOCAL\n" }, { "from": "gpt", "value": "Param(\n [string]$build_number = \"55555\"\n)\n\n# Print the script name\n\"Script: $MyInvocation.MyCommand.Name\"\n\n<#\n@ECHO OFF\nREM ---------------------------------------------------------------------------\nREM Builds the file utility nuget packages.\nREM ---------------------------------------------------------------------------\n\n// /p:PackageVersion=1.0.13-alpha /p:Version=1.0.13.55555\n#>\n\n$package_version = Get-Content \"ver.platform.txt\"\n'$package_version=' + $package_version\n\n$split_version = $package_version.Split(\"-\")[0]\n'$split_version=' + $split_version\n\n'$build_number=' + $build_number\n\n$version_with_build_number = $split_version + \".\" + $build_number\n'$version_with_build_number=' + $version_with_build_number\n\n$assemblies = @(\n \"SoundMetrics.Aris.Comms\"\n \"SoundMetrics.Aris.Config\"\n \"SoundMetrics.Aris.FrameHeaderInjection\"\n \"SoundMetrics.Aris.Messages\"\n \"SoundMetrics.Aris.ReorderCS\"\n \"SoundMetrics.NativeMemory\"\n)\n\n'$assemblies: ' + $assemblies\n\nForeach ($el in $assemblies) {\n ''\n '---------------------------------------------------------------------'\n \"Packing $el\"\n '---------------------------------------------------------------------'\n dotnet pack -c Release /p:Version=$split_version /p:PackageVersion=$package_version $el\n}\n<#\nSETLOCAL\n\nSET BUILD_NUMBER=%1\nIF \"%BUILD_NUMBER%\" == \"\" SET BUILD_NUMBER=55555\nECHO BUILD_NUMBER=%BUILD_NUMBER%\n\nSET /p VERSION=<ver.platform.txt\n\nECHO Making packages for %VERSION%.%BUILD_NUMBER%\n\nSET PACKCMD=dotnet pack -c Release /p:Version=%VERSION%\nECHO PACKCMD=%PACKCMD%\n\nSET PROJECTS=SoundMetrics.Aris.Comms SoundMetrics.Aris.Config SoundMetrics.Aris.FrameHeaderInjection\nSET PROJECTS=%PROJECTS% SoundMetrics.Aris.Messages SoundMetrics.Aris.ReorderCS SoundMetrics.NativeMemory\n\nFOR %%p in (%PROJECTS%) do (\n ECHO ---------------------------------------------------------------------\n ECHO %%p\n ECHO ---------------------------------------------------------------------\n %PACKCMD% %%p\n)\n\nENDLOCAL\n#>\n" } ]
powershell
chosen
[ { "from": "system", "value": "Remove again failing releaser tests on windows" }, { "from": "human", "value": "$image=Get-Childitem -Include *.image -Recurse -Name\n\necho $image\n\n.\\GlamorousToolkitWin64-*\\GlamorousToolkitConsole.exe $image examples --junit-xml-output 'GToolkit-.*' 'GT4SmaCC-.*' 'DeepTraverser-.*' 'Brick' 'Brick-.*' 'Bloc-*' 'Bloc' \n\n# rm .\\GToolkit-Releaser-*\nrm .\\GToolkit-Documenter-XDoc-Examples.xml\n" }, { "from": "gpt", "value": "$image=Get-Childitem -Include *.image -Recurse -Name\n\necho $image\n\n.\\GlamorousToolkitWin64-*\\GlamorousToolkitConsole.exe $image examples --junit-xml-output 'GToolkit-.*' 'GT4SmaCC-.*' 'DeepTraverser-.*' 'Brick' 'Brick-.*' 'Bloc-*' 'Bloc' \n\nrm .\\GToolkit-Releaser-*\nrm .\\GToolkit-Documenter-XDoc-Examples.xml\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use machine instead of user path and use Get-AppInstallLocation for path addition\n" }, { "from": "human", "value": "$ErrorActionPreference = 'Stop';\n\n$toolsPath = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n\n$pp = Get-PackageParameters\n$silentArgs = '/silent','/sp-','/suppressmsgboxes'\n\nif ($pp.InstallDir) {\n $dir = $pp.InstallDir \n}\nelse {\n $dir = \"$($env:ProgramFiles)\\OpenSSL\"\n}\n\n$silentArgs += @(\"/DIR=`\"$dir`\"\")\n\n$packageArgs = @{\n packageName = 'OpenSSL.Light'\n fileType = 'exe'\n file = \"$toolsPath\\Win32OpenSSL_Light-1_1_0f.exe\"\n file64 = \"$toolsPath\\Win64OpenSSL_Light-1_1_0f.exe\"\n softwareName = 'OpenSSL*Light*'\n silentArgs = $silentArgs\n validExitCodes = @(0)\n}\n\nInstall-ChocolateyInstallPackage @packageArgs\n$binPath = \"$($dir)\\bin\" \nInstall-ChocolateyPath -PathToInstall $binPath \n\nRemove-Item -Force -ea 0 \"$toolsPath\\*.exe\",\"$toolsPath\\*.ignore\"\n" }, { "from": "gpt", "value": "$ErrorActionPreference = 'Stop';\n\n$toolsPath = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n\n$pp = Get-PackageParameters\n$silentArgs = '/silent','/sp-','/suppressmsgboxes'\nif ($pp.InstallDir) { $silentArgs += @(\"/DIR=`\"$($pp.InstallDir)`\"\") }\nelse {\n $silentArgs += @(\"/DIR=`\"$env:ProgramFiles\\OpenSSL`\"\")\n}\n\n$packageArgs = @{\n packageName = 'OpenSSL.Light'\n fileType = 'exe'\n file = \"$toolsPath\\Win32OpenSSL_Light-1_1_0f.exe\"\n file64 = \"$toolsPath\\Win64OpenSSL_Light-1_1_0f.exe\"\n softwareName = 'OpenSSL*Light*'\n silentArgs = $silentArgs\n validExitCodes = @(0)\n}\n\nInstall-ChocolateyInstallPackage @packageArgs\n\n$installLocation = Get-AppInstallLocation $packageArgs.softwareName\n$binPath = \"$($installLocation)\\bin\" \n\nif(Test-Path $installLocation ) {\n Install-ChocolateyPath -PathToInstall $binPath -PathType Machine \n}\nelse {\n Write-Warning \"Could not add install directory to path\"\n}\n\nRemove-Item -Force -ea 0 \"$toolsPath\\*.exe\",\"$toolsPath\\*.ignore\"\n" } ]
powershell
chosen
[ { "from": "system", "value": "Put in a generic server path" }, { "from": "human", "value": "#Map a drive\n<<<<<<< HEAD\nNew-PSDrive -Persist -Name 'I' -PSProvider 'FileSystem' -Root \"\\\\ushapwp00029\\pxestore\\BL_Software\" \n=======\nNew-PSDrive -Persist -Name 'I' -PSProvider \"FileSystem\" -Root \"\\\\WindowsShare\" \n>>>>>>> origin/master\n" }, { "from": "gpt", "value": "#Map a drive\n<<<<<<< HEAD\nNew-PSDrive -Persist -Name 'I' -PSProvider 'FileSystem' -Root \"\\\\server\\path\" \n=======\nNew-PSDrive -Persist -Name 'I' -PSProvider \"FileSystem\" -Root \"\\\\WindowsShare\" \n>>>>>>> origin/master\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use process.start to invoke bit cli v1 from bit cli v1 task to check its exit code\n" }, { "from": "human", "value": "[CmdletBinding()]\nparam()\n\nImport-VstsLocStrings \"$PSScriptRoot\\task.json\"\n\n[string]$action = Get-VstsInput -Name Action\n[string]$path = Get-VstsInput -Name Path\n\n./bin/BitCLIV1.exe -a $action -p $path" }, { "from": "gpt", "value": "[CmdletBinding()]\nparam()\n\nImport-VstsLocStrings \"$PSScriptRoot\\task.json\"\n\n[string]$action = Get-VstsInput -Name Action\n[string]$path = Get-VstsInput -Name Path\n[string]$bitCLIV1Exe = $PSScriptRoot + \"\\\\bin\\\\BitCLIV1.exe\"\n\n#[string]$action = \"Generate\"\n#[string]$path = \"D:\\bit-foundation\\BitSampleApp\\SampleApp.sln\"\n#[string]$bitCLIV1Exe = \"D:\\bit-foundation\\bit-framework\\BitTools\\BitCLIV1Task\\buildtask\\bin\\BitCLIV1.exe\"\n\n$proc = New-Object System.Diagnostics.Process\n$proc.StartInfo.UseShellExecute = $false\n$proc.StartInfo.RedirectStandardOutput = $true\n$proc.StartInfo.FileName = $bitCLIV1Exe\n$proc.StartInfo.Arguments = \" -a \" + $action + \" -p \" + $path\n$proc.StartInfo.CreateNoWindow = $true\n\n$proc.Start()\n\n$proc.WaitForExit()\n\nWrite-Host $proc.StandardOutput.ReadToEnd()\n\nif(-not ($proc.ExitCode -eq 0)) {\n throw \"Bit CLI V1 failed\"\n}\nelse {\n Write-Host \"Bit CLI V1 Success\";\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Remove stable and latest branch\n" }, { "from": "human", "value": "$ver = [regex]::Match((Get-Content Build/Version.csproj), '<Version>([^<]+)<').Groups[1].Value\ngit tag -a \"v$ver\" -m \"$ver\"\ngit checkout latest\ngit merge master\ngit checkout master\ngit tag -d \"stable\"\ngit tag -a \"stable\" -m \"stable\"\ngit push origin latest master \"v$ver\" --force\n" }, { "from": "gpt", "value": "$ver = [regex]::Match((Get-Content Build/Version.csproj), '<Version>([^<]+)<').Groups[1].Value\ngit tag -a \"v$ver\" -m \"$ver\"\ngit checkout master\ngit push origin \"v$ver\" --force\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add /p:DeployExtension=false to tooling build script" }, { "from": "human", "value": "Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1' -OutFile .\\build\\dotnet-install.ps1\n.\\build\\dotnet-install.ps1 -channel Current -version 2.1.3 -InstallDir dotnetsdk\ndotnet --version\ndotnet pack Blazor.sln --configuration Release\ncmd /c \"C:\\Program Files (x86)\\Microsoft Visual Studio\\aspnetci\\Enterprise\\MSBuild\\15.0\\Bin\\MSBuild.exe\" BlazorTooling.sln /t:Restore\ncmd /c \"C:\\Program Files (x86)\\Microsoft Visual Studio\\aspnetci\\Enterprise\\MSBuild\\15.0\\Bin\\MSBuild.exe\" BlazorTooling.sln\n" }, { "from": "gpt", "value": "Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1' -OutFile .\\build\\dotnet-install.ps1\n.\\build\\dotnet-install.ps1 -channel Current -version 2.1.3 -InstallDir dotnetsdk\ndotnet --version\ndotnet pack Blazor.sln --configuration Release\ncmd /c \"C:\\Program Files (x86)\\Microsoft Visual Studio\\aspnetci\\Enterprise\\MSBuild\\15.0\\Bin\\MSBuild.exe\" BlazorTooling.sln /t:Restore\ncmd /c \"C:\\Program Files (x86)\\Microsoft Visual Studio\\aspnetci\\Enterprise\\MSBuild\\15.0\\Bin\\MSBuild.exe\" BlazorTooling.sln /p:DeployExtension=false\n" } ]
powershell
chosen
[ { "from": "system", "value": "Improve regex to add -H option\n" }, { "from": "human", "value": "Write-Host \"WARNING: DO NOT USE DOCKER IN PRODUCTION WITHOUT TLS\"\nWrite-Host \"Enabling Docker insecure port 2375\"\n\nif (!(Get-NetFirewallRule | where {$_.Name -eq \"Dockerinsecure2375\"})) {\n New-NetFirewallRule -Name \"Dockerinsecure2375\" -DisplayName \"Docker insecure on TCP/2375\" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True\n}\n\nWrite-Host \"Enabling Docker to listen on insecure port 2375\"\ncp C:\\ProgramData\\docker\\runDockerDaemon.cmd C:\\ProgramData\\docker\\runDockerDaemon.cmd.bak\ncat C:\\ProgramData\\docker\\runDockerDaemon.cmd.bak | %{$_ -replace '^dockerd -H npipe://$','dockerd -H npipe:// -H 0.0.0.0:2375'} | Set-Content C:\\ProgramData\\docker\\runDockerDaemon.cmd\n" }, { "from": "gpt", "value": "Write-Host \"WARNING: DO NOT USE DOCKER IN PRODUCTION WITHOUT TLS\"\nWrite-Host \"Enabling Docker insecure port 2375\"\n\nif (!(Get-NetFirewallRule | where {$_.Name -eq \"Dockerinsecure2375\"})) {\n New-NetFirewallRule -Name \"Dockerinsecure2375\" -DisplayName \"Docker insecure on TCP/2375\" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True\n}\n\nWrite-Host \"Enabling Docker to listen on insecure port 2375\"\ncp C:\\ProgramData\\docker\\runDockerDaemon.cmd C:\\ProgramData\\docker\\runDockerDaemon.cmd.bak\ncat C:\\ProgramData\\docker\\runDockerDaemon.cmd.bak | %{$_ -replace '^dockerd -H npipe://\\s*$','dockerd -H npipe:// -H 0.0.0.0:2375'} | Set-Content C:\\ProgramData\\docker\\runDockerDaemon.cmd\n" } ]
powershell
chosen
[ { "from": "system", "value": "Disable NLA for RDP access" }, { "from": "human", "value": "winrm quickconfig -q\nwinrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'\nwinrm set winrm/config/service/auth '@{Basic=\"true\"}'\nStart-Service WinRM\nset-service WinRM -StartupType Automatic\n" }, { "from": "gpt", "value": "winrm quickconfig -q\nwinrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'\nwinrm set winrm/config/service/auth '@{Basic=\"true\"}'\nStart-Service WinRM\nset-service WinRM -StartupType Automatic\n\n(Get-WmiObject -class Win32_TSGeneralSetting -Namespace root\\cimv2\\terminalservices).SetUserAuthenticationRequired(0)\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add a GetEmployeesPaged PowerShell sample\n" }, { "from": "gpt", "value": "Clear-Host\r\n\r\n$rootFolder = (Get-ChildItem -Path \".\")[0].Directory.Parent.FullName;\r\n$job = Start-Job -ArgumentList $rootFolder -ScriptBlock {\r\n\r\n param($sdkRoot)\r\n\r\n Add-Type -AssemblyName System.Configuration\r\n $sdkPath = \"$sdkRoot\\Deploy\\TimeLog.TransactionalApi.SDK.dll\"\r\n $configPath = \"$sdkRoot\\TimeLog.PowerShell\\App.config\"\r\n Write-Host \"#########################################\"\r\n Write-Host SDK Path: $sdkPath\r\n Write-Host Config Path: $configPath\r\n Write-Host \"#########################################\"\r\n\r\n [System.AppDomain]::CurrentDomain.SetData(\"APP_CONFIG_FILE\", $configPath)\r\n\r\n #[Reflection.Assembly]::LoadFrom(\"..\\Deploy\\TimeLog.TransactionalApi.SDK.dll\")\r\n Add-Type -Path $sdkPath\r\n\r\n $messages = $null\r\n\r\n Write-Host \"Trying to authenticate with transactional API...\"\r\n if ([TimeLog.TransactionalApi.SDK.SecurityHandler]::Instance.TryAuthenticate([ref]$messages) -eq $true) {\r\n Write-Host(\"Successfully authenticated on transactional API!\")\r\n\r\n $page = 1\r\n $fetchMorePages = $true\r\n\r\n while ($fetchMorePages) {\r\n\r\n $getEmployeesPagedRaw = [TimeLog.TransactionalApi.SDK.OrganisationHandler]::Instance.OrganisationClient.GetEmployeesPaged(\r\n $page,\r\n 10,\r\n [TimeLog.TransactionalApi.SDK.OrganisationHandler]::Instance.Token)\r\n\r\n if ($getEmployeesPagedRaw.ResponseState -eq \"Success\") {\r\n Write-Host \"Successfully fetched the list for page $page!\"\r\n\r\n Write-Host Results: $getEmployeesPagedRaw.Return.Length\r\n Write-Host Total pages: $getEmployeesPagedRaw.TotalPageCount\r\n\r\n #foreach ($obj in $getWorkPagedWithExternalIdsRaw.Return) {\r\n #Write-Host ($obj.ID.ToString())\r\n #}\r\n\r\n Write-Host Messages:\r\n foreach ($message in $getEmployeesPagedRaw.Messages) {\r\n Write-Host (\">> \" + $message.Message)\r\n } \r\n }\r\n else {\r\n Write-Host ResponseState: $getEmployeesPagedRaw.ResponseState\r\n Write-Host Messages:\r\n foreach ($message in $getEmployeesPagedRaw.Messages) {\r\n Write-Host (\">> \" + $message.Message)\r\n } \r\n }\r\n\r\n $page = $page + 1\r\n if ($getEmployeesPagedRaw.Return.Length -gt 0) {\r\n $fetchMorePages = $true\r\n } else {\r\n $fetchMorePages = $false\r\n }\r\n }\r\n }\r\n else {\r\n Write-Host \"Failed with the following messages: \"\r\n foreach ($message in $messages) {\r\n Write-Host \">> $message\"\r\n }\r\n }\r\n}\r\nWait-Job $job\r\nReceive-Job $job" } ]
powershell
chosen
[ { "from": "human", "value": "Add a script to hook our post build steps\n" }, { "from": "gpt", "value": "<#\n.SYNOPSIS\nPerforms any post-build actions needed on the Roslyn build systems.\n\n.PARAMETER BinariesDirectory\nThe root directory where the build outputs are written: e:\\path\\to\\source\\Binaries\\Debug\n\n.PARAMETER SourceDirectory\nThe root directory where the sources are checked out: e:\\path\\to\\source\n\n#>\nparam(\n [string]$binariesDirectory,\n [string]$sourceDirectory,\n)\n\nset-strictmode -version 2.0\n$ErrorActionPreference=\"Stop\"\n\ntry\n{\n write-host \"Post Build Steps\"\n\n exit 0\n}\ncatch [exception]\n{\n write-error -Exception $_.Exception\n exit -1\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix path to IIS bin.\n" }, { "from": "human", "value": "param([string]$buildFolder)\r\n\r\n$outputPath = \"..\\output\";\r\n$sitePath = \"$($buildFolder)\\src\\WebSite\"\r\n$port = 58537\r\n$delay = 5000\r\n\r\nWrite-Host \"Running IIS Express from '$($sitePath)'.\"\r\nStart-Process \"C:\\Program Files (x86)\\IIS Express\\iisexpress.exe\" -NoNewWindow -ArgumentList \"/path:$($sitePath) /port:$($port)\"\r\n\r\nWrite-Host \"Waiting $($delay).\"\r\nStart-Sleep -Milliseconds $delay\r\n\r\nWrite-Host \"Running StaticSiteCrawler.\"\r\n#Start-Process \"$($buildFolder)\\Tools\\StaticSiteCrawler.cmd\" -Wait\r\n.\\Tools\\StaticSiteCrawler.exe http://localhost:$($port)/ $outputPath /\r\n\r\nWrite-Host \"Content of output:\"\r\n$items = Get-ChildItem -Path $outputPath\r\nForEach ($item in $items) \r\n{ \r\n $size = (Get-Item \"$($outputPath)\\$($item)\").Length\r\n Write-Host \"$($item) - $($size)B\"\r\n}\r\n\r\nWrite-Host \"Stopping IIS Express.\"\r\nStop-Process -Name iisexpress" }, { "from": "gpt", "value": "param([string]$buildFolder)\r\n\r\n$outputPath = \"..\\output\";\r\n$sitePath = \"$($buildFolder)\\src\\WebSite\\bin\"\r\n$port = 58537\r\n$delay = 5000\r\n\r\nWrite-Host \"Running IIS Express from '$($sitePath)' at '$($port)'.\"\r\nStart-Process \"C:\\Program Files (x86)\\IIS Express\\iisexpress.exe\" -NoNewWindow -ArgumentList \"/path:$($sitePath) /port:$($port)\"\r\n\r\nWrite-Host \"Waiting $($delay).\"\r\nStart-Sleep -Milliseconds $delay\r\n\r\nWrite-Host \"Running StaticSiteCrawler.\"\r\n#Start-Process \"$($buildFolder)\\Tools\\StaticSiteCrawler.cmd\" -Wait\r\n.\\Tools\\StaticSiteCrawler.exe http://localhost:$($port)/ $outputPath /\r\n\r\nWrite-Host \"Content of output:\"\r\n$items = Get-ChildItem -Path $outputPath\r\nForEach ($item in $items) \r\n{ \r\n $size = (Get-Item \"$($outputPath)\\$($item)\").Length\r\n Write-Host \"'$($item)' - $($size)B\"\r\n}\r\n\r\nWrite-Host \"Stopping IIS Express.\"\r\nStop-Process -Name iisexpress" } ]
powershell
chosen
[ { "from": "system", "value": "Add test case for UseDeclaredVarsMoreThanAssignment\n" }, { "from": "human", "value": "Import-Module PSScriptAnalyzer\n$violationMessage = \"The variable 'declaredVar2' is assigned but never used.\"\n$violationName = \"PSUseDeclaredVarsMoreThanAssignments\"\n$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$violations = Invoke-ScriptAnalyzer $directory\\UseDeclaredVarsMoreThanAssignments.ps1 | Where-Object {$_.RuleName -eq $violationName}\n$noViolations = Invoke-ScriptAnalyzer $directory\\UseDeclaredVarsMoreThanAssignmentsNoViolations.ps1 | Where-Object {$_.RuleName -eq $violationName}\n\nDescribe \"UseDeclaredVarsMoreThanAssignments\" {\n Context \"When there are violations\" {\n It \"has 2 use declared vars more than assignments violations\" {\n $violations.Count | Should Be 2\n }\n\n It \"has the correct description message\" {\n $violations[1].Message | Should Match $violationMessage\n }\n\n }\n\n Context \"When there are no violations\" {\n It \"returns no violations\" {\n $noViolations.Count | Should Be 0\n }\n }\n}" }, { "from": "gpt", "value": "Import-Module PSScriptAnalyzer\n$violationMessage = \"The variable 'declaredVar2' is assigned but never used.\"\n$violationName = \"PSUseDeclaredVarsMoreThanAssignments\"\n$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$violations = Invoke-ScriptAnalyzer $directory\\UseDeclaredVarsMoreThanAssignments.ps1 | Where-Object {$_.RuleName -eq $violationName}\n$noViolations = Invoke-ScriptAnalyzer $directory\\UseDeclaredVarsMoreThanAssignmentsNoViolations.ps1 | Where-Object {$_.RuleName -eq $violationName}\n\nDescribe \"UseDeclaredVarsMoreThanAssignments\" {\n Context \"When there are violations\" {\n It \"has 2 use declared vars more than assignments violations\" {\n $violations.Count | Should Be 2\n }\n\n It \"has the correct description message\" {\n $violations[1].Message | Should Match $violationMessage\n }\n\n It \"flags the variable in the correct scope\" {\n $target = @'\nfunction MyFunc1() {\n $a = 1\n $b = 1\n $a + $b\n}\n\nfunction MyFunc2() {\n $a = 1\n $b = 1\n $a + $a\n}\n'@\n $local:violations = Invoke-ScriptAnalyzer -ScriptDefinition $target -IncludeRule $violationName\n $local:violations.Count | Should Be 1\n }\n }\n\n Context \"When there are no violations\" {\n It \"returns no violations\" {\n $noViolations.Count | Should Be 0\n }\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Add missing appveyor test update\n\nReports mstest results to appveyor\n" }, { "from": "human", "value": "param (\n\t[string]$configuration = \"Release\"\n)\n. \"$(resolve-path .\\packages\\nspec.*\\tools\\NSpecRunner.exe)\" --formatter=XmlFormatter Winston.Test\\bin\\$configuration\\Winston.Test.dll > nspec_results.xml\n[xml]$res = Get-Content .\\nspec_results.xml\nforeach($c in $res.Contexts.Context) {\n $spec = $c.Context.Specs.Spec\n foreach($s in $spec) {\n $name = \"$($c.Name) $($s.Name)\"\n $status = $s.Status\n Add-AppveyorTest -Name $name -Outcome $status\n }\n}" }, { "from": "gpt", "value": "param (\n\t[string]$configuration = \"Release\"\n)\n\nfunction NSpec {\n . \"$(resolve-path .\\packages\\nspec.*\\tools\\NSpecRunner.exe)\" --formatter=XmlFormatter Winston.Test\\bin\\$configuration\\Winston.Test.dll > nspec_results.xml\n [xml]$res = Get-Content .\\nspec_results.xml\n foreach($c in $res.Contexts.Context) {\n $spec = $c.Context.Specs.Spec\n foreach($s in $spec) {\n $name = \"$($c.Name) $($s.Name)\"\n $status = $s.Status\n Add-AppveyorTest -Name $name -Outcome $status\n }\n }\n}\n\nfunction MSTest {\n mstest /testcontainer:\"$(Resolve-Path **\\bin\\$configuration\\Winston.Test.dll)\" /resultsfile:TestResults\\ci.trx\n [xml]$trx = Get-Content TestResults\\ci.trx\n $results = $trx.TestRun.Results.UnitTestResult | select testName,outcome,duration\n foreach($r in $results) {\n Add-AppveyorTest -Name \"$r.testName\" -Outcome $r.outcome -Duration $r.duration\n }\n}\n\nNSpec\nMSTest\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add Script for checking long path lentgh\n" }, { "from": "gpt", "value": "# Verifies Length of file path for all files in the SourceDirectory.\n# Breaks if file path is 260 characters or more\nparam(\n [Parameter(Mandatory = $true)][string]$ServiceDirectory\n)\n$ServiceDir = If ( $ServiceDirectory -eq '*') { 'sdk' } Else { \"sdk/$($ServiceDirectory)\" }\nWrite-Output \"Analyzing Path Lengths in $($ServiceDir) ...\"; $LongestPath = ''; $LongestPathLength = 0\nGet-ChildItem -Path \"./$($ServiceDir)\" -Recurse -File | ForEach-Object {\n if ($_.FullName.Length -gt $LongestPathLength) {\n $LongestPathLength = $_.FullName.Length; $LongestPath = $_.FullName \n if ($LongestPathLength -ge 260) { Write-Output \"$($LongestPath) : is 260 or more Characters long. Reduce path length\"; exit 1 }\n } }\nWrite-Output \"The Longest path ($($LongestPath)) is $($LongestPathLength) characters long\"" } ]
powershell
chosen
[ { "from": "system", "value": "Add missing source base parameter\n" }, { "from": "human", "value": "$version=$(select-string -Path Dockerfile -Pattern \"ENV DOCKER_VERSION\").ToString().split()[-1]\ndocker tag docker-cli stefanscherer/docker-cli-windows:$version-1607\ndocker push stefanscherer/docker-cli-windows:$version-1607\n\nnpm install -g rebase-docker-image\nrebase-docker-image `\n stefanscherer/docker-cli-windows:$version-1607 `\n -t stefanscherer/docker-cli-windows:$version-1709 `\n -b stefanscherer/netapi-helper:1709\n\n..\\update-docker-cli.ps1\n\ndocker manifest create `\n stefanscherer/docker-cli-windows:$version `\n stefanscherer/docker-cli-windows:$version-1607 `\n stefanscherer/docker-cli-windows:$version-1709\ndocker manifest push stefanscherer/docker-cli-windows:$version\n\ndocker manifest create `\n stefanscherer/docker-cli-windows:latest `\n stefanscherer/docker-cli-windows:$version-1607 `\n stefanscherer/docker-cli-windows:$version-1709\ndocker manifest push stefanscherer/docker-cli-windows:latest\n" }, { "from": "gpt", "value": "$version=$(select-string -Path Dockerfile -Pattern \"ENV DOCKER_VERSION\").ToString().split()[-1]\ndocker tag docker-cli stefanscherer/docker-cli-windows:$version-1607\ndocker push stefanscherer/docker-cli-windows:$version-1607\n\nnpm install -g rebase-docker-image\nrebase-docker-image `\n stefanscherer/docker-cli-windows:$version-1607 `\n -s microsoft/nanoserver:10.0.14393.2189 `\n -t stefanscherer/docker-cli-windows:$version-1709 `\n -b stefanscherer/netapi-helper:1709\n\n..\\update-docker-cli.ps1\n\ndocker manifest create `\n stefanscherer/docker-cli-windows:$version `\n stefanscherer/docker-cli-windows:$version-1607 `\n stefanscherer/docker-cli-windows:$version-1709\ndocker manifest push stefanscherer/docker-cli-windows:$version\n\ndocker manifest create `\n stefanscherer/docker-cli-windows:latest `\n stefanscherer/docker-cli-windows:$version-1607 `\n stefanscherer/docker-cli-windows:$version-1709\ndocker manifest push stefanscherer/docker-cli-windows:latest\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update format, Add Error handling\n" }, { "from": "human", "value": "function Set-PowerShellWindowTitle\n{\n<#\n .SYNOPSIS\n Function to set the title of the PowerShell Window\n\n .DESCRIPTION\n Function to set the title of the PowerShell Window\n\n .PARAMETER Title\n Specifies the Title of the PowerShell Window\n\n .EXAMPLE\n PS C:\\> Set-PowerShellWindowTitle -Title LazyWinAdmin.com\n\n .NOTES\n Francois-Xavier Cat\n lazywinadmin.com\n @lazywinadmin\n#>\n PARAM($Title)\n $Host.UI.RawUI.WindowTitle = $Title\n}\n\n" }, { "from": "gpt", "value": "function Set-PowerShellWindowTitle {\n <#\n .SYNOPSIS\n Function to set the title of the PowerShell Window\n\n .DESCRIPTION\n Function to set the title of the PowerShell Window\n\n .PARAMETER Title\n Specifies the Title of the PowerShell Window\n\n .EXAMPLE\n PS C:\\> Set-PowerShellWindowTitle -Title LazyWinAdmin.com\n\n .NOTES\n Francois-Xavier Cat\n lazywinadmin.com\n @lazywinadmin\n#>\n [CmdletBinding()]\n PARAM($Title)\n try {\n $Host.UI.RawUI.WindowTitle = $Title\n }\n catch {\n $PSCmdlet.ThrowTerminatingError($_)\n }\n}\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add Azure SQL IaC script'\n" }, { "from": "gpt", "value": "param($serverPrefix, $envName, $dbName, $resourceGroupName, $location = 'Brazil South' $adminUser, $adminPassword)\n\n# Get/create Server\n\n$creds = New-Object System.Management.Automation.PSCredential($adminUser, (ConvertTo-SecureString $adminPassword -AsPlainText -Force))\n$serverName = \"$serverPrefix-$envName\".ToLower()\n\nWrite-Output 'Create server $serverName if needed'\n\n$svr = (Get-AzureRmSqlServer -ServerName $serverName -ResourceGroupName $resourceGroupName -ErrorAction SilentlyContinue)\n\nif(-not $svr)\n{\n Write-Output 'Server $serverName not found; creating new SQL Server'\n\n # Create server\n $svr = New-AzureRmSqlServer -ServerName $serverName -ResourceGroupName $resourceGroupName -SqlAdministratorCredentials $creds -Location $location\n\n $svr | Format-List\n\n # Add firewall rule to access server from Azure services\n New-AzureRmSqlServerFirewallRule -ServerName $serverName -FirewallRuleName \"Azure IPs\" -StartIpAddress 0.0.0.0 -EndIpAddress 0.0.0.0 -ResourceGroupName $resourceGroupName\n}\nelse\n{\n Write-Output 'Server $serverName already exists; skipping'\n}\n\n# Get/create database\n\n$db = (Get-AzureRmSqlDatabase -DatabaseName $dbName -ServerName $serverName -ResourceGroupName $resourceGroupName -ErrorAction SilentlyContinue)\n\nWrite-Output 'Create database $dbName if needed'\n\nif (-not $db)\n{\n Write-Output 'Database $dbName not found; creating new database'\n\n # Create database\n New-AzureRmSqlDatabase -DatabaseName $dbName -ServerName $serverName -ResourceGroupName $resourceGroupName\n}\n\n# Output server FQDN\n\nWrite-Output \"Outputting server name $($svr.FullyQualifiedDomainName) to the pipeline as variable 'SqlServerFQDN'\"\n\nWrite-Host \"##vso[task.setvariable variable=SqlServerFQDN;]$($svr.FullyQualifiedDomainName))\"\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add a script to fix browser project references after updating CEF\n" }, { "from": "gpt", "value": "$ErrorActionPreference = \"Stop\"\n\n$MainProj = \"..\\TweetDuck.csproj\"\n$BrowserProj = \"..\\subprocess\\TweetDuck.Browser.csproj\"\n\n$Match = Select-String -Path $MainProj '<Import Project=\"packages\\\\CefSharp\\.Common\\.(.*?)\\\\'\n$Version = $Match.Matches[0].Groups[1].Value\n\n$Contents = [IO.File]::ReadAllText($BrowserProj)\n$Contents = $Contents -Replace '(?<=<HintPath>\\.\\.\\\\packages\\\\CefSharp\\.Common\\.)(.*?)(?=\\\\)', $Version\n$Contents = $Contents -Replace '(?<=<Reference Include=\"CefSharp\\.BrowserSubprocess\\.Core, Version=)(\\d+)', $Version.Split(\".\")[0]\n\n[IO.File]::WriteAllText($BrowserProj, $Contents)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Put the main code into a main function.\n" }, { "from": "human", "value": "param\r\n(\r\n [string]$cloudbaseinitdir\r\n)\r\n\r\n$patch_code = @'\r\nfrom mock import patch\r\n\r\n\r\ndef custom_getattribute(self, attr):\r\n value = object.__getattribute__(self, attr)\r\n if attr == '_router_ip' and value:\r\n return value.split(':')[0]\r\n return value\r\n\r\nif __name__ == '__main__':\r\n with patch('cloudbaseinit.metadata.services.cloudstack.'\r\n 'CloudStack.__getattribute__', custom_getattribute): \r\n from cloudbaseinit._shell import main\r\n main()\r\n'@\r\n\r\nmv $cloudbaseinitdir\\shell.py $cloudbaseinitdir\\_shell.py -ErrorAction ignore\r\nrm $cloudbaseinitdir\\shell.pyc -ErrorAction ignore\r\necho $patch_code | Out-File -Encoding utf8 $cloudbaseinitdir\\shell.py\r\n" }, { "from": "gpt", "value": "param\r\n(\r\n [string]$cloudbaseinitdir\r\n)\r\n\r\n$patch_code = @'\r\nfrom mock import patch\r\n\r\n\r\ndef custom_getattribute(self, attr):\r\n value = object.__getattribute__(self, attr)\r\n if attr == '_router_ip' and value:\r\n return value.split(':')[0]\r\n return value\r\n\r\ndef main():\r\n with patch('cloudbaseinit.metadata.services.cloudstack.'\r\n 'CloudStack.__getattribute__', custom_getattribute): \r\n from cloudbaseinit._shell import main as orig_main\r\n orig_main()\r\n\r\nif __name__ == '__main__':\r\n main()\r\n\r\n'@\r\n\r\nmv $cloudbaseinitdir\\shell.py $cloudbaseinitdir\\_shell.py -ErrorAction ignore\r\nrm $cloudbaseinitdir\\shell.pyc -ErrorAction ignore\r\necho $patch_code | Out-File -Encoding utf8 $cloudbaseinitdir\\shell.py\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Change profile to Private to avoid infinite wait\n\nI've run into an infinite wait scenario when trying to build without the additional line added. While debugging I ran this script from an Administrator Powershell window and the error was always the same, the WinRM -quickconfig command isn't getting the profile override so isn't allowing WinRM o be enabled preventing the initial Packer wait for WinRM to succeed.\n\nObvious fix.\n" }, { "from": "human", "value": "Write-Host \"Performing the WinRM setup necessary to get the host ready for packer to run Chef...\"\n\n# parts of this are from https://github.com/luciusbono/Packer-Windows10/blob/master/configure-winrm.ps1\n# and https://github.com/rgl/windows-2016-vagrant/blob/master/winrm.ps1\n\n# Supress network location Prompt\nNew-Item -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Network\\NewNetworkWindowOff\" -Force\n\n# Does a lot: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-6\nEnable-PSRemoting -SkipNetworkProfileCheck -Force\nSet-NetFirewallRule -Name \"WINRM-HTTP-In-TCP\" -RemoteAddress Any # allow winrm over public profile interfaces\n\nwinrm set \"winrm/config\" '@{MaxTimeoutms=\"1800000\"}'\nwinrm set \"winrm/config/winrs\" '@{MaxMemoryPerShellMB=\"2048\"}'\nwinrm set \"winrm/config/service\" '@{AllowUnencrypted=\"true\"}'\nwinrm set \"winrm/config/service/auth\" '@{Basic=\"true\"}'\n\nexit 0\n" }, { "from": "gpt", "value": "Write-Host \"Performing the WinRM setup necessary to get the host ready for packer to run Chef...\"\n\n# parts of this are from https://github.com/luciusbono/Packer-Windows10/blob/master/configure-winrm.ps1\n# and https://github.com/rgl/windows-2016-vagrant/blob/master/winrm.ps1\n\n# Supress network location Prompt\nNew-Item -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Network\\NewNetworkWindowOff\" -Force\n\n# The above suppresses the prompt but defaults to \"Public\" which prevents WinRM from being enabled even with the SkipNetworkProfileCheck arg\n# This command sets any network connections detected to Private to allow WinRM to be configured and started\nGet-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory \"Private\"\n\n# Does a lot: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-6\nEnable-PSRemoting -SkipNetworkProfileCheck -Force\n# May not be necessary since we set the profile to Private above\nSet-NetFirewallRule -Name \"WINRM-HTTP-In-TCP\" -RemoteAddress Any # allow winrm over public profile interfaces\n\nwinrm set \"winrm/config\" '@{MaxTimeoutms=\"1800000\"}'\nwinrm set \"winrm/config/winrs\" '@{MaxMemoryPerShellMB=\"2048\"}'\nwinrm set \"winrm/config/service\" '@{AllowUnencrypted=\"true\"}'\nwinrm set \"winrm/config/service/auth\" '@{Basic=\"true\"}'\n\nexit 0\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix the issue of CR fot Get-Culture\n" }, { "from": "human", "value": "Describe \"Get-Culture DRT Unit Tests\" -Tags DRT{\n It \"Should works proper with get-culture\" {\n $results = get-Culture\n $results | Should Not BeNullOrEmpty \n $results[0].GetType() | Should Be CultureInfo\n $results[0].Name | Should Be $PSCulture\n }\n}\n\nDescribe \"Get-Culture\" {\n\n It \"Should return a type of CultureInfo for Get-Culture cmdlet\" {\n\n\t(Get-Culture).GetType() | Should Be CultureInfo\n\n }\n\n It \"Should have $ culture variable be equivalent to (Get-Culture).Name\" {\n\n\t(Get-Culture).Name | Should Be $PsCulture\n\n }\n\n\n}\n" }, { "from": "gpt", "value": "Describe \"Get-Culture DRT Unit Tests\" -Tags DRT{\n It \"Should works proper with get-culture\" {\n $results = get-Culture\n $results -is \"System.Globalization.CultureInfo\" | Should be $true\n $results[0].Name | Should Be $PSCulture\n }\n}\n\nDescribe \"Get-Culture\" {\n\n It \"Should return a type of CultureInfo for Get-Culture cmdlet\" {\n\n\t(Get-Culture).GetType() | Should Be CultureInfo\n\n }\n\n It \"Should have $ culture variable be equivalent to (Get-Culture).Name\" {\n\n\t(Get-Culture).Name | Should Be $PsCulture\n\n }\n\n\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Remove s from the function name\n" }, { "from": "human", "value": "function Remove-StringLatinCharacters\n{\n<#\n.SYNOPSIS\n Function to remove diacritics from a string\n.EXAMPLE\n Remove-StringLatinCharacters -String \"L'été de Raphaël\"\n\n L'ete de Raphael\n.EXAMPLE\n Foreach ($file in (Get-ChildItem c:\\test\\*.txt))\n {\n # Get the content of the current file and remove the diacritics\n $NewContent = Get-content $file | Remove-StringLatinCharacters\n \n # Overwrite the current file with the new content\n $NewContent | Set-Content $file\n }\n\n Remove diacritics from multiple files\n\n.NOTES\n Francois-Xavier Cat\n @lazywinadm\n github.com/lazywinadmin\n\n BLOG ARTICLE\n http://www.lazywinadmin.com/2015/05/powershell-remove-diacritics-accents.html\n\t\n VERSION HISTORY\n 1.0.0.0 | Francois-Xavier Cat\n Initial version Based on Marcin Krzanowic code\n 1.0.0.1 | Francois-Xavier Cat\n Added support for ValueFromPipeline\n#>\n\tPARAM (\n\t\t[Parameter(ValueFromPipeline=$true)]\n\t\t[System.String]$String\n\t\t)\n\tPROCESS\n\t{\n\t\t[Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding(\"Cyrillic\").GetBytes($String))\n\t}\n}" }, { "from": "gpt", "value": "function Remove-StringLatinCharacter\n{\n<#\n.SYNOPSIS\n Function to remove diacritics from a string\n.EXAMPLE\n Remove-StringLatinCharacter -String \"L'été de Raphaël\"\n\n L'ete de Raphael\n.EXAMPLE\n Foreach ($file in (Get-ChildItem c:\\test\\*.txt))\n {\n # Get the content of the current file and remove the diacritics\n $NewContent = Get-content $file | Remove-StringLatinCharacter\n \n # Overwrite the current file with the new content\n $NewContent | Set-Content $file\n }\n\n Remove diacritics from multiple files\n\n.NOTES\n Francois-Xavier Cat\n @lazywinadm\n github.com/lazywinadmin\n\n BLOG ARTICLE\n http://www.lazywinadmin.com/2015/05/powershell-remove-diacritics-accents.html\n\t\n VERSION HISTORY\n 1.0.0.0 | Francois-Xavier Cat\n Initial version Based on Marcin Krzanowic code\n 1.0.0.1 | Francois-Xavier Cat\n Added support for ValueFromPipeline\n#>\n\tPARAM (\n\t\t[Parameter(ValueFromPipeline=$true)]\n\t\t[System.String]$String\n\t\t)\n\tPROCESS\n\t{\n\t\t[Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding(\"Cyrillic\").GetBytes($String))\n\t}\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Add statements to debug hanging install script.\n" }, { "from": "human", "value": "#!/usr/bin/env powershell\n\n# Using relative paths works both on appveyor and in development workstations\ncd ..\n\n# ... update or clone the vcpkg package manager ...\nif (Test-Path vcpkg\\.git) {\n cd vcpkg\n git pull\n} elseif (Test-Path vcpkg\\installed) {\n move vcpkg vcpkg-tmp\n git clone https://github.com/Microsoft/vcpkg\n move vcpkg-tmp\\installed vcpkg\n cd vcpkg\n} else {\n git clone https://github.com/Microsoft/vcpkg\n cd vcpkg\n}\n\n# ... build the tool each time, it is fast to do so ...\npowershell -exec bypass scripts\\bootstrap.ps1\n\n# ... integrate installed packages into the build environment ...\n.\\vcpkg integrate install\n\n# ... if necessary, install grpc again. Normally the packages are\n# cached by the CI system (appveyor) so this is not too painful ...\n.\\vcpkg install zlib:x86-windows-static\n.\\vcpkg install openssl:x86-windows-static\n.\\vcpkg install protobuf:x86-windows-static\n.\\vcpkg install grpc:x86-windows-static\n\ncd ..\\cpp-docs-samples\n" }, { "from": "gpt", "value": "#!/usr/bin/env powershell\n\n# Using relative paths works both on appveyor and in development workstations\ncd ..\n\n# ... update or clone the vcpkg package manager ...\nif (Test-Path vcpkg\\.git) {\n cd vcpkg\n git pull\n} elseif (Test-Path vcpkg\\installed) {\n move vcpkg vcpkg-tmp\n git clone https://github.com/Microsoft/vcpkg\n move vcpkg-tmp\\installed vcpkg\n cd vcpkg\n} else {\n git clone https://github.com/Microsoft/vcpkg\n cd vcpkg\n}\n\n# ... build the tool each time, it is fast to do so ...\npowershell -exec bypass scripts\\bootstrap.ps1\n\n# ... integrate installed packages into the build environment ...\n.\\vcpkg integrate install\n\n.\\vcpkg list\n\n# ... if necessary, install grpc again. Normally the packages are\n# cached by the CI system (appveyor) so this is not too painful ...\n.\\vcpkg install zlib:x86-windows-static\n#.\\vcpkg install openssl:x86-windows-static\n#.\\vcpkg install protobuf:x86-windows-static\n#.\\vcpkg install grpc:x86-windows-static\n\ncd ..\\cpp-docs-samples\n" } ]
powershell
chosen
[ { "from": "system", "value": "Enable standard checkpoint on VM for snapshot if disabled\n" }, { "from": "human", "value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId,\n [string]$SnapName\n)\n\n$ErrorActionPreference = \"Stop\"\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n Hyper-V\\Checkpoint-VM $VM -SnapshotName $SnapName\n} catch {\n Write-ErrorMessage \"Failed to create snapshot: ${PSItem}\"\n exit 1\n}\n" }, { "from": "gpt", "value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId,\n [string]$SnapName\n)\n\n$ErrorActionPreference = \"Stop\"\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n $ChkPnt = $VM.CheckpointType\n if($ChkPnt -eq \"Disabled\") {\n Hyper-V\\Set-VM -VM $VM -CheckpointType \"Standard\"\n }\n Hyper-V\\Checkpoint-VM $VM -SnapshotName $SnapName\n if($ChkPnt -eq \"Disabled\") {\n Hyper-V\\Set-VM -VM $VM -CheckpointType \"Disabled\"\n }\n} catch {\n Write-ErrorMessage \"Failed to create snapshot: ${PSItem}\"\n exit 1\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add PackageManagement acceptance test cases\n" }, { "from": "gpt", "value": "#\n# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n# ------------------ PackageManagement Test -----------------------------------\n\n$InternalGallery = \"https://dtlgalleryint.cloudapp.net/api/v2/\"\n$InternalSource = 'OneGetTestSource'\n\n\nDescribe \"PackageManagement Acceptance Test\" -Tags \"Feature\" {\n \n BeforeAll{\n Register-PackageSource -Name Nugettest -provider NuGet -Location https://www.nuget.org/api/v2 -force\n Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue\n\n }\n It \"get-packageprovider\" {\n \n $gpp = Get-PackageProvider\n \n $gpp | ?{ $_.name -eq \"NuGet\" } | should not BeNullOrEmpty\n \n $gpp | ?{ $_.name -eq \"PowerShellGet\" } | should not BeNullOrEmpty \n }\n\n\n It \"find-packageprovider PowerShellGet\" {\n $fpp = (Find-PackageProvider -Name \"PowerShellGet\" -force).name \n $fpp -contains \"PowerShellGet\" | should be $true\n }\n\n It \"install-packageprovider, Expect succeed\" {\n $ipp = (install-PackageProvider -name gistprovider -force -source $InternalSource).name \n $ipp -contains \"gistprovider\" | should be $true \n }\n \n\n it \"Find-package\" {\n $f = Find-Package -ProviderName NuGet -Name jquery -source Nugettest\n $f.Name -contains \"jquery\" | should be $true\n\t}\n\n it \"Install-package\" {\n $i = install-Package -ProviderName NuGet -Name jquery -force -source Nugettest\n $i.Name -contains \"jquery\" | should be $true\n\t}\n\n it \"Get-package\" {\n $g = Get-Package -ProviderName NuGet -Name jquery\n $g.Name -contains \"jquery\" | should be $true\n\t}\n\n it \"save-package\" {\n $s = save-Package -ProviderName NuGet -Name jquery -path $TestDrive -force -source Nugettest\n $s.Name -contains \"jquery\" | should be $true\n\t}\n\n it \"uninstall-package\" {\n $u = uninstall-Package -ProviderName NuGet -Name jquery\n $u.Name -contains \"jquery\" | should be $true\n\t}\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add argument completer for settings parameter\n" }, { "from": "human", "value": "#\n# Script module for module 'PSScriptAnalyzer'\n#\nSet-StrictMode -Version Latest\n\n# Set up some helper variables to make it easier to work with the module\n$PSModule = $ExecutionContext.SessionState.Module\n$PSModuleRoot = $PSModule.ModuleBase\n\n# Import the appropriate nested binary module based on the current PowerShell version\n$binaryModuleRoot = $PSModuleRoot\n\n\nif (($PSVersionTable.Keys -contains \"PSEdition\") -and ($PSVersionTable.PSEdition -ne 'Desktop')) {\n $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr'\n}\nelse\n{\n if ($PSVersionTable.PSVersion -lt [Version]'5.0') {\n $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv3'\n } \n}\n\n$binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll'\n$binaryModule = Import-Module -Name $binaryModulePath -PassThru\n\n# When the module is unloaded, remove the nested binary module that was loaded with it\n$PSModule.OnRemove = {\n Remove-Module -ModuleInfo $binaryModule\n}" }, { "from": "gpt", "value": "#\n# Script module for module 'PSScriptAnalyzer'\n#\nSet-StrictMode -Version Latest\n\n# Set up some helper variables to make it easier to work with the module\n$PSModule = $ExecutionContext.SessionState.Module\n$PSModuleRoot = $PSModule.ModuleBase\n\n# Import the appropriate nested binary module based on the current PowerShell version\n$binaryModuleRoot = $PSModuleRoot\n\n\nif (($PSVersionTable.Keys -contains \"PSEdition\") -and ($PSVersionTable.PSEdition -ne 'Desktop')) {\n $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr'\n}\nelse\n{\n if ($PSVersionTable.PSVersion -lt [Version]'5.0') {\n $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv3'\n }\n}\n\n$binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll'\n$binaryModule = Import-Module -Name $binaryModulePath -PassThru\n\n# When the module is unloaded, remove the nested binary module that was loaded with it\n$PSModule.OnRemove = {\n Remove-Module -ModuleInfo $binaryModule\n}\n\nif (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)\n{\n Register-ArgumentCompleter -CommandName 'Invoke-ScriptAnalyzer' -ParameterName 'Settings' -ScriptBlock {\n param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParmeter)\n [Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper]::GetBuiltinSettingPresets() | `\n Where-Object {$_ -like \"$wordToComplete*\"} | `\n ForEach-Object { New-Object System.Management.Automation.CompletionResult $_ }\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Use Nuget.org API key from environment variable rather than committing to source control...\n" }, { "from": "human", "value": "[CmdletBinding(SupportsShouldProcess = $true)]\nparam()\n\nwrite-verbose \"Preparing to push packages...\"\n\n$scriptDir = $MyInvocation.MyCommand.Path | split-path\n$outputDir = \"$scriptDir\\nugets\"\nwrite-debug \"outputDir = $outputDir\"\n\nmd $outputDir -f | out-null\n\ngci \"$outputDir\\*\" -filter *.nupkg | \n Foreach-Object { \n Write-Host -ForegroundColor Green \"$_\"\n\n if ($PSCmdLet.ShouldProcess(\"Push $($_.Fullname) to default source\")) {\n dotnet nuget push $_.FullName --source nuget.org --api-key oy2hbbqsxchsjmxxf7samqp2vpisl2bujjaaxjhtc4bxkq\n }\n }\n" }, { "from": "gpt", "value": "[CmdletBinding(SupportsShouldProcess = $true)]\nparam()\n\nwrite-verbose \"Preparing to push packages...\"\n\n$scriptDir = $MyInvocation.MyCommand.Path | split-path\n$outputDir = \"$scriptDir\\nugets\"\nwrite-debug \"outputDir = $outputDir\"\n\nmd $outputDir -f | out-null\n\ngci \"$outputDir\\*\" -filter *.nupkg | \n Foreach-Object { \n Write-Host -ForegroundColor Green \"$_\"\n\n if ($PSCmdLet.ShouldProcess(\"Push $($_.Fullname) to default source\")) {\n dotnet nuget push $_.FullName --source nuget.org --api-key $env:NugetOrgApiKey\n }\n }\n" } ]
powershell
chosen
[ { "from": "system", "value": "[StandardPublishingCMS] Fix on Setup-Lists for PUB01. Pages library configurations was not applied on source web.\n" }, { "from": "human", "value": "# -----------------------------------------------------------------------\n# Copyright\t\t: GSoft @2014\n# Model \t\t: Cross Site Publishing CMS\n# File : Setup-Lists.ps1.template\n# Description\t: Setup pages library\n# -----------------------------------------------------------------------\n\nWrite-Warning \"Applying Pages Library configuration...\"\n\n# Activate features on all publishing sites (sources an targets)\n[[DSP_PublishingTargetRootWebUrls]] | Foreach-Object{\n\n\tInitialize-DSPFeature -Url $_ -Id [[DSP_CommonCMS_PUB_Lists]]\n}\n\n" }, { "from": "gpt", "value": "# -----------------------------------------------------------------------\n# Copyright\t\t: GSoft @2014\n# Model \t\t: Cross Site Publishing CMS\n# File : Setup-Lists.ps1.template\n# Description\t: Setup pages library\n# -----------------------------------------------------------------------\n\nWrite-Warning \"Applying Pages Library configuration...\"\n\n# Activate features on all publishing sites (source an targets)\n\nWrite-Warning \"Applying Pages Library configuration...\"\n\n# Activate features on all publishing sites (source an targets)\n\n[[DSP_PublishingSourceRootWebUrls]] | Foreach-Object{\n\n\tInitialize-DSPFeature -Url $_ -Id [[DSP_CommonCMS_PUB_Lists]]\n}\n\n[[DSP_PublishingTargetRootWebUrls]] | Foreach-Object{\n\n\tInitialize-DSPFeature -Url $_ -Id [[DSP_CommonCMS_PUB_Lists]]\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Connect to swarm manager in container\n" }, { "from": "gpt", "value": "$ip = $(docker inspect --format '{{ json .NetworkSettings.Networks.nat.IPAddress }}' swarm-master)\ndocker run -d -p 9000:9000 portainer/portainer:windows -H tcp://$($ip):2375 --swarm\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add bash wrapper for PowerShell\n" }, { "from": "gpt", "value": "function _bashRun($cmdString) {\n $acceptableExitCode = 0\n # This is unfortunately necessary because there is an interfacing issue between the windows console, windows containers, and MSYS2\n # Specifically, all of STDOUT and STDERR are lost when executing commands under those circumstances.\n cd \"${env:TEMP}\"\n $unixTemp = (& bash -c \"pwd\").Trim()\n _log \"Executing BASH command '$cmdString' in working directory '$unixTemp'\"\n $unixOut = \"$unixTemp/bashRunOutput\"\n $exec = \"bash.exe\"\n $arguments = (\"-c\", \"'echo BASH COMMAND OUTPUT BEGINS >`\"$unixOut`\" && cd `\"$unixTemp`\" >>`\"$unixOut`\" 2>&1 && $cmdString >>`\"$unixOut`\" 2>&1 && echo BASH COMMAND OUTPUT EOF >>`\"$unixOut`\"'\")\n $p = Start-Process -FilePath $exec -ArgumentList $arguments -Wait -PassThru\n cat \"${myTemp}\\bashRunOutput\"\n _log \"Process finished. Got exit code: $($p.ExitCode)\"\n if($p.ExitCode -ne $acceptableExitCode) {\n _die \"Expected ${acceptableExitCode}!\"\n }\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix new-collector wmi members initialization\n" }, { "from": "human", "value": "Param(\n [Parameter(Mandatory=$true)]\n $Class,\n [Parameter(Mandatory=$false)]\n $CollectorName = ($Class -replace 'Win32_PerfRawData_Perf',''),\n [Parameter(Mandatory=$false)]\n $ComputerName = \"localhost\",\n [Parameter(Mandatory=$false)]\n $Credential\n)\n$ErrorActionPreference = \"Stop\"\n\nif($Credential -ne $null) {\n $wmiObject = Get-WMIObject -ComputerName $ComputerName -Credential $Credential -Class $Class\n}\nelse {\n $wmiObject = Get-WMIObject -ComputerName $ComputerName -Class $Class\n}\n\n$members = $wmiObject `\n | Get-Member -MemberType Properties `\n | Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } `\n | Select-Object Name, @{Name=\"Type\";Expression={$_.Definition.Split(\" \")[0]}}\n$input = @{\n \"Class\"=$Class;\n \"CollectorName\"=$CollectorName;\n \"Members\"=$members\n} | ConvertTo-Json\n$outFileName = \"..\\..\\collector\\$CollectorName.go\".ToLower()\n$input | .\\collector-generator.exe | Out-File -NoClobber -Encoding UTF8 $outFileName\ngo fmt $outFileName\n" }, { "from": "gpt", "value": "Param(\n [Parameter(Mandatory=$true)]\n $Class,\n [Parameter(Mandatory=$false)]\n $CollectorName = ($Class -replace 'Win32_PerfRawData_Perf',''),\n [Parameter(Mandatory=$false)]\n $ComputerName = \"localhost\",\n [Parameter(Mandatory=$false)]\n $Credential\n)\n$ErrorActionPreference = \"Stop\"\n\nif($Credential -ne $null) {\n $wmiObject = Get-WMIObject -ComputerName $ComputerName -Credential $Credential -Class $Class\n}\nelse {\n $wmiObject = Get-WMIObject -ComputerName $ComputerName -Class $Class\n}\n\n$members = @($wmiObject `\n | Get-Member -MemberType Properties `\n | Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } `\n | Select-Object Name, @{Name=\"Type\";Expression={$_.Definition.Split(\" \")[0]}}\n$input = @{\n \"Class\"=$Class;\n \"CollectorName\"=$CollectorName;\n \"Members\"=$members\n} | ConvertTo-Json)\n$outFileName = \"..\\..\\collector\\$CollectorName.go\".ToLower()\n$input | .\\collector-generator.exe | Out-File -NoClobber -Encoding UTF8 $outFileName\ngo fmt $outFileName\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use uppercase Name for getting vm name\n" }, { "from": "human", "value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId\n)\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n $Disks = @(Hyper-V\\Get-VMHardDiskDrive -VMName $VM.name)\n} catch {\n Write-ErrorMessage \"Failed to retrieve all disk info from ${VM}: ${PSItem}\"\n exit 1\n}\n\n$result = ConvertTo-json $Disks\nWrite-OutputMessage $result\n" }, { "from": "gpt", "value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId\n)\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n $Disks = @(Hyper-V\\Get-VMHardDiskDrive -VMName $VM.Name)\n} catch {\n Write-ErrorMessage \"Failed to retrieve all disk info from ${VM}: ${PSItem}\"\n exit 1\n}\n\n$result = ConvertTo-json $Disks\nWrite-OutputMessage $result\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix typo in property name\n" }, { "from": "human", "value": "$TestAdapter = [PSObject]@{\n Name = (Get-NetAdapter -Physical | Select-Object -First 1).Name\n PhysicalMediaType = '802.3'\n Status = 'Up'\n}\n\n\nconfiguration MSFT_xNetworkAdapterName_Config {\n Import-DscResource -ModuleName xNetworking\n node localhost {\n xNetworkAdapterName Integration_Test {\n Name = $TestAdapter.InterfaceAlias\n PhysicalMediaType = $TestAdapter.PhysicalMediaType\n Status = $TestAdapter.Status\n }\n }\n}\n" }, { "from": "gpt", "value": "$TestAdapter = [PSObject]@{\n Name = (Get-NetAdapter -Physical | Select-Object -First 1).Name\n PhysicalMediaType = '802.3'\n Status = 'Up'\n}\n\n\nconfiguration MSFT_xNetworkAdapterName_Config {\n Import-DscResource -ModuleName xNetworking\n node localhost {\n xNetworkAdapterName Integration_Test {\n Name = $TestAdapter.Name\n PhysicalMediaType = $TestAdapter.PhysicalMediaType\n Status = $TestAdapter.Status\n }\n }\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add template bootstrap script for windows\n" }, { "from": "gpt", "value": "#User variables\n$SystemPrepMasterScriptUrl = 'https://url/to/masterscript.ps1'\n$SystemPrepParams = @{\n Param1 = \"Value1\"\n Param2 = \"Value2\"\n Param3 = \"Value3\"\n Param4 = \"Value4\"\n}\n\n#System variables\n$DateTime = $(get-date -format \"yyyyMMdd_HHmm_ss\")\n$ScriptName = $MyInvocation.mycommand.name\n$SystemPrepDir = \"${env:SystemDrive}\\SystemPrep\"\n$SystemPrepLogFile = \"${SystemPrepDir}\\SystemPrep-Log_${DateTime}.txt\"\n\nfunction log {\n\t[CmdLetBinding()]\n\tParam(\n\t\t[Parameter(Mandatory=$true,Position=0,ValueFromPipeLine=$true,ValueFromPipeLineByPropertyName=$true)] [string[]] $LogMessage\n\t)\n\tPROCESS {\n\t\t#Writes the input $LogMessage to the log file $SystemPrepLogFile.\n\t\tAdd-Content -Path $SystemPrepLogFile -Value \"$(get-date -format `\"yyyyMMdd_HHmm_ss`\"): ${ScriptName}: ${LogMessage}\"\n\t}\n}\n\nif (-Not (Test-Path $SystemPrepDir)) { New-Item -Path $SystemPrepDir -ItemType \"directory\" -Force > $null; log \"Created SystemPrep directory -- ${SystemPrepDir}\" } else { log \"SystemPrep directory already exists -- $SystemPrepDir\" }\n$ScriptFileName = (${SystemPrepMasterScriptUrl}.split('/'))[-1]\n$ScriptFullPath = \"${SystemPrepDir}\\${ScriptFileName}\"\nlog \"Downloading the SystemPrep master script -- ${SystemPrepMasterScriptUrl}\"\n((new-object net.webclient).DownloadFile(\"${SystemPrepMasterScriptUrl}\",\"${ScriptFullPath}\") 2>&1) | log\nlog \"Running the SystemPrep master script -- ${ScriptFullPath}\"\n(Invoke-Expression \"& ${ScriptFullPath} @SystemPrepParams\" 2>&1) | log\nlog \"Exiting SystemPrep BootStrap script\"\n" } ]
powershell
chosen
[ { "from": "system", "value": "Correct typo, $Enable instead of $enabled.\n" }, { "from": "human", "value": "#Requires -Modules VagrantVM, VagrantMessages\n\nparam (\n [parameter (Mandatory=$true)]\n [string] $VMID,\n [parameter (Mandatory=$true)]\n [string] $Name,\n [parameter (Mandatory=$false)]\n [switch] $Enable\n)\n\n$ErrorActionPreference = \"Stop\"\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VMID\n} catch {\n Write-Error-Message \"Failed to locate VM: ${PSItem}\"\n exit 1\n}\n\ntry {\n Set-VagrantVMService -VM $VM -Name $Name -Enable $enabled\n} catch {\n if($enabled){ $action = \"enable\" } else { $action = \"disable\" }\n Write-Error-Message \"Failed to ${action} VM integration service ${Name}: ${PSItem}\"\n exit 1\n}\n" }, { "from": "gpt", "value": "#Requires -Modules VagrantVM, VagrantMessages\n\nparam (\n [parameter (Mandatory=$true)]\n [string] $VMID,\n [parameter (Mandatory=$true)]\n [string] $Name,\n [parameter (Mandatory=$false)]\n [switch] $Enable\n)\n\n$ErrorActionPreference = \"Stop\"\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VMID\n} catch {\n Write-Error-Message \"Failed to locate VM: ${PSItem}\"\n exit 1\n}\n\ntry {\n Set-VagrantVMService -VM $VM -Name $Name -Enable $Enable\n} catch {\n if($Enable){ $action = \"enable\" } else { $action = \"disable\" }\n Write-Error-Message \"Failed to ${action} VM integration service ${Name}: ${PSItem}\"\n exit 1\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add a vscode extension installation\n" }, { "from": "human", "value": "# Script to install extensions for Visual Studio Code\n\n\n# Install Language Extensions\n## golang\ncode --force --install-extension golang.go\n\n## Python\ncode --force --install-extension ms-python.python\ncode --force --install-extension ms-python.vscode-pylance\ncode --force --install-extension njpwerner.autodocstring\n\n## C++\ncode --force --install-extension ms-vscode.cpptools\n\n## Shell Script\ncode --force --install-extension timonwong.shellcheck\ncode --force --install-extension jetmartin.bats\n\n## TypeScript\ncode --force --install-extension ms-vscode.vscode-typescript-tslint-plugin\n\n## etc\ncode --force --install-extension bungcip.better-toml\ncode --force --install-extension ms-vscode-remote.vscode-remote-extensionpack\ncode --force --install-extension yzhang.markdown-all-in-one\ncode --force --install-extension lextudio.restructuredtext\ncode --force --install-extension redhat.vscode-yaml\n\n\n# Install Application Specific Extensions\n## docker\ncode --force --install-extension ms-azuretools.vscode-docker\n\n## Git\ncode --force --install-extension eamodio.gitlens\n\n## Jupyter Notebook\ncode --force --install-extension ms-toolsai.jupyter\n\n## PlantUML\ncode --force --install-extension jebbs.plantuml\n" }, { "from": "gpt", "value": "# Script to install extensions for Visual Studio Code\n\n\n# Install Language Extensions\n## golang\ncode --force --install-extension golang.go\n\n## Python\ncode --force --install-extension ms-python.python\ncode --force --install-extension ms-python.vscode-pylance\ncode --force --install-extension njpwerner.autodocstring\n\n## C++\ncode --force --install-extension ms-vscode.cpptools\n\n## Shell Script\ncode --force --install-extension timonwong.shellcheck\ncode --force --install-extension jetmartin.bats\n\n## TypeScript\ncode --force --install-extension ms-vscode.vscode-typescript-tslint-plugin\n\n## etc\ncode --force --install-extension asciidoctor.asciidoctor-vscode\ncode --force --install-extension bungcip.better-toml\ncode --force --install-extension ms-vscode-remote.vscode-remote-extensionpack\ncode --force --install-extension yzhang.markdown-all-in-one\ncode --force --install-extension lextudio.restructuredtext\ncode --force --install-extension redhat.vscode-yaml\n\n\n# Install Application Specific Extensions\n## docker\ncode --force --install-extension ms-azuretools.vscode-docker\n\n## Git\ncode --force --install-extension eamodio.gitlens\n\n## Jupyter Notebook\ncode --force --install-extension ms-toolsai.jupyter\n\n## PlantUML\ncode --force --install-extension jebbs.plantuml\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add script to clear Windows Explorer shell bags\n" }, { "from": "gpt", "value": "[CmdletBinding(SupportsShouldProcess)]\nParam()\n\n$RegPaths = @(\n 'HKCU:\\Software\\Microsoft\\Windows\\Shell',\n 'HKCU:\\Software\\Microsoft\\Windows\\ShellNoRoam',\n 'HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell'\n)\n\nif ([Environment]::Is64BitOperatingSystem) {\n $RegPaths += 'HKCU:\\Software\\Classes\\Wow6432Node\\Local Settings\\Software\\Microsoft\\Windows\\Shell'\n}\n\nforeach ($RegPath in $RegPaths) {\n $RegPathBags = Join-Path -Path $RegPath -ChildPath 'Bags'\n $RegPathBagMRU = Join-Path -Path $RegPath -ChildPath 'BagMRU'\n\n foreach ($RegPathToRemove in @($RegPathBags, $RegPathBagMRU)) {\n if ($PSCmdlet.ShouldProcess($RegPathToRemove, 'Remove')) {\n try {\n Remove-Item -Path $RegPathToRemove -Recurse -ErrorAction Stop\n } catch {\n switch -Regex ($PSItem.FullyQualifiedErrorId) {\n '^PathNotFound,' { }\n Default { throw }\n }\n }\n }\n }\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Allow test on every system\n" }, { "from": "human", "value": "PowerShell -NoProfile -Command {\n $folder = 'C:\\sources\\serviceable-objects\\Examples\\TestHttpCompositionConsoleApp\\bin\\Debug\\netcoreapp1.0';\n Set-Location -Path $folder;\n Import-Module \"$folder\\TestHttpCompositionConsoleApp.dll\" -Verbose;\n\n #Get-Help Write-Message;\n Write-Message -Message \"hey\" -PipeName \"testpipe\" -NodeId \"log-context\";\n\n # Target examples:\n # Run-InstrumentationCommandOnCustomPipe -Pipe XXX -Data \"hey\" -OtherData \"lo\"\n # Run-InstrumentationCommandOnNode -Service XXX -ServiceContainer YYY -NodeId log-context -Data \"hey\" -OtherData \"lo\"\n # Do-SomethingOnServiceProcess -Service XXX -ServiceContainer YYY (add-node? merge-template? pause-service?, etc)\n # Do-SomethingOnServiceContainerProcess -ServiceContainer YYY (copy-service?, move-service?, update-service?, etc)\n\n Write-Host \"Done.\";\n}" }, { "from": "gpt", "value": "$location = Split-Path $MyInvocation.MyCommand.Path;\n\nPowerShell -NoProfile -Command {\n param (\n [String] $location\n )\n\n $folder = \"$location\\bin\\Debug\\netcoreapp1.0\";\n Set-Location -Path $folder;\n Import-Module \"$folder\\TestHttpCompositionConsoleApp.dll\" -Verbose;\n\n #Get-Help Write-Message;\n Write-Message -Message \"hey\" -PipeName \"testpipe\" -NodeId \"log-context\";\n\n # Target examples:\n # Run-InstrumentationCommandOnCustomPipe -Pipe XXX -Data \"hey\" -OtherData \"lo\"\n # Run-InstrumentationCommandOnNode -Service XXX -ServiceContainer YYY -NodeId log-context -Data \"hey\" -OtherData \"lo\"\n # Do-SomethingOnServiceProcess -Service XXX -ServiceContainer YYY (add-node? merge-template? pause-service?, etc)\n # Do-SomethingOnServiceContainerProcess -ServiceContainer YYY (copy-service?, move-service?, update-service?, etc)\n\n Write-Host \"Done.\";\n} -args $location" } ]
powershell
chosen
[ { "from": "system", "value": "Add Get-FileHash function as alias\n" }, { "from": "human", "value": "sv DESKTOP (Join-Path $HOME Desktop) -Option ReadOnly, AllScope\nsv DOWNLOADS (Join-Path $HOME Downloads) -Option ReadOnly, AllScope\nsv PROFILEDIR (Split-Path $PROFILE) -Option ReadOnly, AllScope\nsv SCRIPTS (Join-Path $HOME Scripts) -Option ReadOnly, AllScope\n\nsal gh help\nsal gcb Get-Clipboard\nsal scb Set-Clipboard\n\nsal d docker\nsal dc docker-compose\nsal dm docker-machine\nsal g git\n\nfunction ll([string[]]$Path = '.') { gci $Path -Exclude .* }\nfunction sl.. { sl .. }\nfunction sl~ { sl ~ }\n\nfunction prompt {\n\t$Host.UI.RawUI.WindowTitle = \"PS $($ExecutionContext.SessionState.Path.CurrentLocation)$('>' * ($NestedPromptLevel + 1))\"\n\treturn 'PS> '\n}\n" }, { "from": "gpt", "value": "sv DESKTOP (Join-Path $HOME Desktop) -Option ReadOnly, AllScope\nsv DOWNLOADS (Join-Path $HOME Downloads) -Option ReadOnly, AllScope\nsv PROFILEDIR (Split-Path $PROFILE) -Option ReadOnly, AllScope\nsv SCRIPTS (Join-Path $HOME Scripts) -Option ReadOnly, AllScope\n\nsal gh help\nsal gcb Get-Clipboard\nsal scb Set-Clipboard\n\nsal d docker\nsal dc docker-compose\nsal dm docker-machine\nsal g git\n\nfunction ll([string[]]$Path = '.') { gci $Path -Exclude .* }\nfunction sl.. { sl .. }\nfunction sl~ { sl ~ }\nfunction Get-FileHash { $fh = Microsoft.PowerShell.Utility\\Get-FileHash @Args; Set-Clipboard $fh.hash; $fh }\n\nfunction prompt {\n\t$Host.UI.RawUI.WindowTitle = \"PS $($ExecutionContext.SessionState.Path.CurrentLocation)$('>' * ($NestedPromptLevel + 1))\"\n\treturn 'PS> '\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix PowerShell version of extractor pack script\n" }, { "from": "human", "value": "cargo build --release\n\ncargo run --release -p ruby-generator -- --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll\ncodeql query format -i ql\\src\\codeql/ruby\\ast\\internal\\TreeSitter.qll\n\nrm -Recurse -Force extractor-pack\nmkdir extractor-pack | Out-Null\ncp codeql-extractor.yml, ql\\src\\ruby.dbscheme, ql\\src\\ruby.dbscheme.stats extractor-pack\ncp -Recurse tools extractor-pack\nmkdir extractor-pack\\tools\\win64 | Out-Null\ncp target\\release\\ruby-extractor.exe extractor-pack\\tools\\win64\\extractor.exe\ncp target\\release\\ruby-autobuilder.exe extractor-pack\\tools\\win64\\autobuilder.exe\n" }, { "from": "gpt", "value": "cargo build --release\n\ncargo run --release -p ruby-generator -- --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll\ncodeql query format -i ql\\lib\\codeql/ruby\\ast\\internal\\TreeSitter.qll\n\nrm -Recurse -Force extractor-pack\nmkdir extractor-pack | Out-Null\ncp codeql-extractor.yml, ql\\lib\\ruby.dbscheme, ql\\lib\\ruby.dbscheme.stats extractor-pack\ncp -Recurse tools extractor-pack\nmkdir extractor-pack\\tools\\win64 | Out-Null\ncp target\\release\\ruby-extractor.exe extractor-pack\\tools\\win64\\extractor.exe\ncp target\\release\\ruby-autobuilder.exe extractor-pack\\tools\\win64\\autobuilder.exe\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix reference to error record\n" }, { "from": "human", "value": "function FormatErrorMessage\n{\n [CmdletBinding()]\n param(\n [Parameter(ValueFromPipeline=$true)]\n $ErrorRecord = $Error[0]\n )\n\n $currentConfig = GetCurrentConfigurationOrDefault\n if ($currentConfig.verboseError) {\n $error_message = \"{0}: An Error Occurred. See Error Details Below: $($script:nl)\" -f (Get-Date)\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += \"Error: {0}$($script:nl)\" -f (ResolveError $_ -Short)\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += ResolveError $_\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += \"Script Variables\" + $script:nl\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += get-variable -scope script | format-table | out-string\n } else {\n # ($_ | Out-String) gets error messages with source information included.\n $error_message = \"Error: {0}: $($script:nl){1}\" -f (Get-Date), (ResolveError $_ -Short)\n}\n\n $error_message\n}\n" }, { "from": "gpt", "value": "function FormatErrorMessage\n{\n [CmdletBinding()]\n param(\n [Parameter(ValueFromPipeline=$true)]\n $ErrorRecord = $Error[0]\n )\n\n $currentConfig = GetCurrentConfigurationOrDefault\n if ($currentConfig.verboseError) {\n $error_message = \"{0}: An Error Occurred. See Error Details Below: $($script:nl)\" -f (Get-Date)\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += \"Error: {0}$($script:nl)\" -f (ResolveError $ErrorRecord -Short)\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += ResolveError $ErrorRecord\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += \"Script Variables\" + $script:nl\n $error_message += (\"-\" * 70) + $script:nl\n $error_message += get-variable -scope script | format-table | out-string\n } else {\n # ($_ | Out-String) gets error messages with source information included.\n $error_message = \"Error: {0}: $($script:nl){1}\" -f (Get-Date), (ResolveError $ErrorRecord -Short)\n}\n\n $error_message\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use correct URL for downloading wincdemu\n" }, { "from": "human", "value": "$tools=\"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\nStart-ChocolateyProcessAsAdmin \"certutil -addstore 'TrustedPublisher' '$tools\\sysprogs.cer'\"\n\n$packageName = '{{PackageName}}'\n$fileType = 'exe'\n$silentArgs = '/UNATTENDED'\n# {\\{DownloadUrlx64}\\} gets “misused” here as 32-bit download link due to limitations of Ketarin/chocopkgup\n$url = '{{DownloadUrlx64}}'\n\nInstall-ChocolateyPackage $packageName $fileType $silentArgs $url\n" }, { "from": "gpt", "value": "$tools=\"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\nStart-ChocolateyProcessAsAdmin \"certutil -addstore 'TrustedPublisher' '$tools\\sysprogs.cer'\"\n\n$packageName = '{{PackageName}}'\n$fileType = 'exe'\n$silentArgs = '/UNATTENDED'\n$url = '{{DownloadUrl}}'\n\nInstall-ChocolateyPackage $packageName $fileType $silentArgs $url\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update project versioning PS script\n" }, { "from": "human", "value": "# This PowerShel script appends AppVeyor build number to the package version.\n\n$projects = Get-ChildItem .\\src | ?{$_.PsIsContainer}\n\nforeach($project in $projects) {\n cd src/$project\n npm install\n node project-version.js\n cd ../../\n}" }, { "from": "gpt", "value": "# This PowerShel script appends AppVeyor build number to the package version.\n\n$projects = Get-ChildItem .\\src | ?{$_.PsIsContainer}\n\nforeach($project in $projects) {\n # Display project name\n $project\n\n # Move to the project\n cd src/$project\n\n # NPM install\n npm install\n\n # Run node.js script\n node project-version.js\n\n # Move back to the solution root\n cd ../../\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Add a PowerShell script to launch soyweb locally\n\nSummary:\nThis is nearly the same as `docs/soyweb-local.sh`, but works on Windows.\n\nI never thought I'd have to look at the binary encoding of a JSON file,\nbut for this diff I had to to figure out that soyweb can't processes a\nUnicode-encoded JSON file.\n\nTest Plan: launched it and loaded it in my browser\n" }, { "from": "gpt", "value": "# Unfortunately, plovr has a bug where we cannot override values in globals.json\n# from the command line. Instead, we create a copy of globals.json with the\n# modifications we need to run soyweb locally and use that.\ntry {\n $tempfile = \"$env:TEMP\\temp\" + (\"{0:d5}\" -f (Get-Random)).Substring(0,5) +\n \"globals.json\"\n Get-Content docs/globals.json |\n ForEach-Object { $_ -replace '/buck', '' } |\n Out-File $tempfile -encoding ASCII\n java -jar docs\\plovr-81ed862.jar soyweb --dir docs --globals $tempfile\n}\nfinally {\n Remove-Item $tempfile\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix handling around empty PublicAPI.txt files\n" }, { "from": "human", "value": "[CmdletBinding(PositionalBinding=$false)]\nparam ()\n\nSet-StrictMode -version 2.0\n$ErrorActionPreference = \"Stop\"\n\nfunction MarkShipped([string]$dir) {\n $shippedFilePath = Join-Path $dir \"PublicAPI.Shipped.txt\"\n $shipped = Get-Content $shippedFilePath\n $unshippedFilePath = Join-Path $dir \"PublicAPI.Unshipped.txt\"\n $unshipped = Get-Content $unshippedFilePath\n $removed = @()\n $removedPrefix = \"*REMOVED*\";\n Write-Host \"Processing $dir\"\n\n foreach ($item in $unshipped) {\n if ($item.StartsWith($removedPrefix)) {\n $item = $item.Substring($removedPrefix.Length)\n $removed += $item\n }\n else {\n $shipped += $item\n }\n }\n\n $shipped | Sort-Object | ?{ -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii\n \"\" | Out-File $unshippedFilePath -Encoding Ascii\n}\n\ntry {\n . (Join-Path $PSScriptRoot \"..\\..\\..\\build\\scripts\\build-utils.ps1\")\n Push-Location $repoDir\n\n foreach ($file in Get-ChildItem -re -in \"PublicApi.Shipped.txt\") {\n $dir = Split-Path -parent $file\n MarkShipped $dir\n }\n}\ncatch {\n Write-Host $_\n Write-Host $_.Exception\n exit 1\n}\nfinally {\n Pop-Location\n}\n" }, { "from": "gpt", "value": "[CmdletBinding(PositionalBinding=$false)]\nparam ()\n\nSet-StrictMode -version 2.0\n$ErrorActionPreference = \"Stop\"\n\nfunction MarkShipped([string]$dir) {\n $shippedFilePath = Join-Path $dir \"PublicAPI.Shipped.txt\"\n $shipped = Get-Content $shippedFilePath\n $unshippedFilePath = Join-Path $dir \"PublicAPI.Unshipped.txt\"\n $unshipped = Get-Content $unshippedFilePath\n $removed = @()\n $removedPrefix = \"*REMOVED*\";\n Write-Host \"Processing $dir\"\n\n foreach ($item in $unshipped) {\n if ($item.Length -gt 0) {\n if ($item.StartsWith($removedPrefix)) {\n $item = $item.Substring($removedPrefix.Length)\n $removed += $item\n }\n else {\n $shipped += $item\n }\n }\n }\n\n $shipped | Sort-Object | ?{ -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii\n \"\" | Out-File $unshippedFilePath -Encoding Ascii\n}\n\ntry {\n . (Join-Path $PSScriptRoot \"..\\..\\..\\build\\scripts\\build-utils.ps1\")\n Push-Location $repoDir\n\n foreach ($file in Get-ChildItem -re -in \"PublicApi.Shipped.txt\") {\n $dir = Split-Path -parent $file\n MarkShipped $dir\n }\n}\ncatch {\n Write-Host $_\n Write-Host $_.Exception\n exit 1\n}\nfinally {\n Pop-Location\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add pre-build script to install KRE and KPM\n" }, { "from": "gpt", "value": "$kpmPath = Join-Path \"$env:USERPROFILE\" \".kpm\"\n$krePath = Join-Path \"$env:USERPROFILE\" \".kre\"\n\n$isKPMExist = Test-Path $kpmPath -PathType Container\n$isKREExist = Test-Path $krePath -PathType Container\n\nif ($isKPMExist -and $isKREExist)\n{\n Write-Host \"KPM [$kpmPath] and KRE [$krePath] exists.\"\n return;\n}\n\n& powershell -NoProfile -ExecutionPolicy Unrestricted -Command \"Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))\"\n\n$KREInstallPath = \"$($env:USERPROFILE)\\.kre\\bin\"\n& powershell -NoProfile -ExecutionPolicy Unrestricted -Command \"& $KREInstallPath\\kvm.cmd upgrade\"" } ]
powershell
chosen
[ { "from": "system", "value": "Implement uploading zip pkg to azure storage using PS.\n" }, { "from": "human", "value": "function Upload-ChefPkgToAzure($publishSettingsFile, $storageAccount, $storageContainer) {\n trap [Exception] {echo $_.Exception.Message;exit 1}\n\n write-host \"Upload-ChefPkgToAzure called with: $publishSettingsFile, $storageAccount, $storageContainer\"\n\n}\n\nExport-ModuleMember -Function Upload-ChefPkgToAzure" }, { "from": "gpt", "value": "function Upload-ChefPkgToAzure($publishSettingsFile, $storageAccount, $storageContainer, $extensionPackageFile) {\n trap [Exception] {echo $_.Exception.Message;exit 1}\n\n write-host \"Upload-ChefPkgToAzure called with: $publishSettingsFile, $storageAccount, $storageContainer, $extensionPackageFile\"\n\n Import-AzurePublishSettingsFile -PublishSettingsFile $publishSettingsFile\n\n # If storageAccount does not exists, create it.\n Get-AzureStorageAccount -StorageAccountName $storageAccount\n if ($? -eq $false) {\n write-host \"Creating $storageAccount storage account... \"\n New-AzureStorageAccount -StorageAccountName $storageAccount -Label 'ChefExtension' -Description \"Store for azure chef extension packages.\" -Location 'West US'\n } else {\n write-host \"$storageAccount storage account already exists.\"\n }\n\n # Get the storage key that needs to be used to create context\n $storageKey = Get-AzureStorageKey -StorageAccountName $storageAccount\n\n $storageContext = New-AzureStorageContext -StorageAccountName $storageAccount -StorageAccountKey $storageKey.Primary\n\n # Create a storage storageContainer if not present\n # with Blob access - read access to blob data but not container\n Get-AzureStorageContainer -Name $storageContainer -Context $storageContext\n if ($? -eq $false) {\n write-host \"Creating $storageContainer storage container... \"\n New-AzureStorageContainer $storageContainer -Permission Blob -Context $storageContext\n } else {\n write-host \"$storageContainer storage container already exists.\"\n }\n\n # Start the zip package upload to storage.\n Set-AzureStorageBlobContent -Container $storageContainer -File $extensionPackageFile -Context $storageContext\n}\n\nExport-ModuleMember -Function Upload-ChefPkgToAzure" } ]
powershell
chosen
[ { "from": "system", "value": "Allow for all acceptable exit codes\n" }, { "from": "human", "value": "$env:PATH +=\";$env:SystemDrive\\ProgramData\\chocolatey\\bin\"\r\n\r\n[[Command]]\r\n\r\nif ($LASTEXITCODE -ne 0) {\r\n\texit 1\r\n}\r\n" }, { "from": "gpt", "value": "$env:PATH +=\";$($env:SystemDrive)\\ProgramData\\chocolatey\\bin\"\r\n# https://github.com/chocolatey/choco/issues/512\r\n$validExitCodes = @(0, 1605, 1614, 1641, 3010)\r\n\r\n[[Command]]\r\n\r\n$exitCode = $LASTEXITCODE\r\n\r\nWrite-Host \"Exit code was $exitCode\"\r\nif ($validExitCodes -contains $exitCode) {\r\n Exit 0\r\n}\r\n\r\nExit $exitCode\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Clean up temporary emu files\n" }, { "from": "human", "value": "param(\n\t[string]$emulatorName = \"AndroidBuildEmulator\" # Name of emulator\n)\n\nWrite-Verbose \"Entering script KillAndroidEmulator.ps1\"\nWrite-Verbose \"emulatorName = $emulatorName\"\n\n$adbexe = $env:ANDROID_HOME + \"\\platform-tools\\adb.exe\"\n$androidbat = $env:ANDROID_HOME + \"\\tools\\android.bat\"\n\n# Delete emulator device. Stop-Process is used because Wait-Job or Stop-Job hangs.\nStop-Process -processname emulator-x86\n& $adbexe kill-server \n& $androidbat delete avd -n $emulatorName\n\nWrite-Verbose \"Leaving script KillAndroidEmulator.ps1\"\n" }, { "from": "gpt", "value": "param(\n\t[string]$emulatorName = \"AndroidBuildEmulator\" # Name of emulator\n)\n\nWrite-Verbose \"Entering script KillAndroidEmulator.ps1\"\nWrite-Verbose \"emulatorName = $emulatorName\"\n\n$adbexe = $env:ANDROID_HOME + \"\\platform-tools\\adb.exe\"\n$androidbat = $env:ANDROID_HOME + \"\\tools\\android.bat\"\n\n# Delete emulator device. Stop-Process is used because Wait-Job or Stop-Job hangs.\nStop-Process -processname emulator-x86\n& $adbexe kill-server \n& $androidbat delete avd -n $emulatorName\n\n# Remove temporary emulator file\n$user = [Environment]::UserName\n$tempDirectory = \"C:\\Users\\\" + $user + \"\\AppData\\Local\\Temp\\AndroidEmulator\"\nif(Test-Path $tempDirectory) {\n\tRemove-Item $tempDirectory -recurse\n}\n\nWrite-Verbose \"Leaving script KillAndroidEmulator.ps1\"\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add click to build powershell script\n" }, { "from": "gpt", "value": "$currentPath = Split-Path $MyInvocation.MyCommand.Path\n$msbuildFile = Join-Path $currentPath src\\VersionTasks.msbuild\n\n& \"$(get-content env:windir)\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe\" $msbuildFile /t:Build\n\nWrite-Host \"Press any key to continue . . .\"\n$x = $host.UI.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\")" } ]
powershell
chosen
[ { "from": "human", "value": "Add unit test for change\n" }, { "from": "gpt", "value": "<# \n.summary\n Test suite for MSFT_xPackageResource.psm1\n#>\n[CmdletBinding()]\nparam()\n\nImport-Module $PSScriptRoot\\..\\DSCResources\\MSFT_xPackageResource\\MSFT_xPackageResource.psm1\n\n$ErrorActionPreference = 'stop'\nSet-StrictMode -Version latest\n\n\nfunction Suite.BeforeAll {\n # Remove any leftovers from previous test runs\n Suite.AfterAll \n\n}\n\nfunction Suite.AfterAll {\n Remove-Module MSFT_xPackageResource\n}\n\nfunction Suite.BeforeEach {\n}\n\ntry\n{\n InModuleScope MSFT_xPackageResource {\n Describe 'Get-RegistryValueIgnoreError' {\n\n It 'Should get values from HKLM' {\n $installValue = Get-RegistryValueIgnoreError 'LocalMachine' \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\" \"ProgramFilesDir\" Registry64\n $installValue | should be $env:programfiles\n }\n It 'Should get values from HKCU' {\n $installValue = Get-RegistryValueIgnoreError 'CurrentUser' \"Environment\" \"Temp\" Registry64\n $installValue | should be $env:temp\n }\n\n }\n }\n}\nfinally\n{\n Suite.AfterAll\n}\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add support for PowerShell v4 and lower in hashtable parsing\n\nSafeGetValue doesn't exist in lower versions of PowerShell which is\ncausing exceptions when trying to run the HelperModule.\n" }, { "from": "human", "value": "function Get-HashtableFromString\n{\n param\n (\n [string]$lineInput\n )\n\n # check for empty first\n If ([String]::IsNullOrEmpty($lineInput.trim(';'))) {\n return @{}\n }\n\n Foreach ($line in ($lineInput -split '(?<=}\\s*),')) {\n # Use the language parser to safely parse the hashtable string into a real hashtable.\n [System.Management.Automation.Language.Parser]::ParseInput($line, [Ref]$null, [Ref]$null).Find({\n $args[0] -is [System.Management.Automation.Language.HashtableAst]\n }, $false).SafeGetValue()\n }\n}\n" }, { "from": "gpt", "value": "function Get-HashtableFromString\n{\n param\n (\n [string]$lineInput\n )\n\n # check for empty first\n If ([String]::IsNullOrEmpty($lineInput.trim(';'))) {\n return @{}\n }\n\n Foreach ($line in ($lineInput -split '(?<=}\\s*),')) {\n $Hashtable = [System.Management.Automation.Language.Parser]::ParseInput($line, [Ref]$null, [Ref]$null).Find({\n $args[0] -is [System.Management.Automation.Language.HashtableAst]\n }, $false)\n\n if ($PSVersionTable.PSVersion.Major -ge 5) {\n # Use the language parser to safely parse the hashtable string into a real hashtable.\n $Hashtable.SafeGetValue()\n }\n else {\n Write-Warning -Message \"PowerShell Version lower than 5 detected. Performing Unsafe hashtable conversion. Please update to version 5 or above when possible for safe conversion of hashtable.\"\n Invoke-Expression -Command $Hashtable.Extent\n }\n }\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add powershell module that was being ignored by git (oops)\n" }, { "from": "gpt", "value": "function Get-Version\n{\n\tparam\n\t(\n\t\t[string]$assemblyInfoFilePath\n\t)\n\tWrite-Host \"path $assemblyInfoFilePath\"\n\t$pattern = '(?<=^\\[assembly\\: AssemblyVersion\\(\\\")(?<versionString>\\d+\\.\\d+\\.\\d+\\.\\d+)(?=\\\"\\))'\n\t$assmblyInfoContent = Get-Content $assemblyInfoFilePath\n\treturn $assmblyInfoContent | Select-String -Pattern $pattern | Select -expand Matches |% {$_.Groups['versionString'].Value}\n}\n\nfunction Update-Version\n{\n\tparam\n (\n\t\t[string]$version,\n\t\t[string]$assemblyInfoFilePath\n\t)\n\n\t$newVersion = 'AssemblyVersion(\"' + $version + '\")';\n\t$newFileVersion = 'AssemblyFileVersion(\"' + $version + '\")';\n\t$tmpFile = $assemblyInfoFilePath + \".tmp\"\n\n\tGet-Content $assemblyInfoFilePath |\n\t\t%{$_ -replace 'AssemblyFileVersion\\(\"[0-9]+(\\.([0-9]+|\\*)){1,3}\"\\)', $newFileVersion } | Out-File -Encoding UTF8 $tmpFile\n\n\tMove-Item $tmpFile $assemblyInfoFilePath -force\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use native powershell for unzipping\n" }, { "from": "human", "value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\nmkdir master\n$shell = new-object -com shell.application\n$zip = $shell.NameSpace(\"C:\\Windows\\Temp\\master.zip\")\nforeach($item in $zip.items())\n{\n $shell.Namespace(\".\\master\").copyhere($item)\n}\n\ncd master\\windows-setup-master\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\nWrite-Host \"Rebooting..\"\nshutdown /r /t 0\n" }, { "from": "gpt", "value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\nmkdir master\n$shell = new-object -com shell.application\n$zip = $shell.NameSpace(\"C:\\Windows\\Temp\\master.zip\")\nforeach($item in $zip.items())\n{\n $shell.Namespace(\".\\master\").copyhere($item)\n}\n\ncd .\\master\\windows-setup-master\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\n# Write-Host \"Rebooting..\"\n# shutdown /r /t 0\n" } ]
powershell
chosen
[ { "from": "system", "value": "Remove a cmdlet from beta cmdlet\n" }, { "from": "human", "value": "# List of beta cmdlets.\n$cmdletsToBeExported = @(\"Get-GcsBucket\")\n$cmdletsToBeExported\n" }, { "from": "gpt", "value": "# List of beta cmdlets.\n$cmdletsToBeExported = @(\"\")\n$cmdletsToBeExported\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix the windows installer script\n" }, { "from": "human", "value": "$ErrorActionPreference = \"Stop\"\n\nIf ($Args.Count -ne 2) {\n echo \"Usage:\"\n echo $Args[0] + \" <BOOTSTRAP TARBALL VERSION>\"\n echo \"Bootstrap tarball version will be compiled into Installer.\"\n echo \"\"\n exit 1\n}\n\necho \"Compiling InstallMeteor\"\necho \"Bootstrap tarball version \" + $Args[1]\n\n# Set the version\n(Get-Content InstallMeteor.cs) | Foreach-Object {$_ -replace '\\[__BOOTSTRAP_VERSION__\\]', $Args[1]} | Out-File InstallMeteor.cs\n\nInvoke-Expression $WINDIR + \"Microsoft.NET\\Framework\\v3.5\\csc.exe InstallMeteor.cs /debug /nologo\"\necho \"Done\"\n\n" }, { "from": "gpt", "value": "$ErrorActionPreference = \"Stop\"\n$script_path = (split-path -parent $MyInvocation.MyCommand.Definition) + \"\\\"\n\nIf ($Args.Count -ne 1) {\n echo \"Usage:\"\n echo \"build-installer.ps1 <BOOTSTRAP TARBALL VERSION>\"\n echo \"Bootstrap tarball version will be compiled into Installer.\"\n echo \"\"\n exit 1\n}\n\necho \"Compiling InstallMeteor\"\necho (\"Bootstrap tarball version \" + $Args[0])\n\n# Set the version\n$version = $Args[0].replace(\"`n\",\"\").replace(\"`r\",\"\")\n(Get-Content ($script_path + \"InstallMeteor.cs\")) | Foreach-Object {$_ -replace '__BOOTSTRAP_VERSION__',$version} | Out-File ($script_path + \"InstallMeteor_.cs\")\n\nInvoke-Expression ($env:WINDIR + \"\\Microsoft.NET\\Framework\\v3.5\\csc.exe /out:\" + $script_path + \"InstallMeteor.exe \" + $script_path + \"InstallMeteor_.cs /debug /nologo\")\necho \"Done\"\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add uninstall script for mp3tag\n" }, { "from": "gpt", "value": "$uninstString = (Get-ChildItem -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',\r\n 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall' |\r\n Get-ItemProperty |\r\n Where-Object {$_.DisplayName -match 'Mp3tag' } |\r\n Select-Object -Property DisplayName, UninstallString).uninstallString\r\n\r\nif ($uninstString) {\r\n Uninstall-ChocolateyPackage '{{PackageName}}' 'exe' '/S' $uninstString\r\n}\r\n" } ]
powershell
chosen