Skip to content

Instantly share code, notes, and snippets.

@moziauddin
Last active August 1, 2019 03:42
Show Gist options
  • Save moziauddin/75fa4a8057f53cc228fe709d80d589e6 to your computer and use it in GitHub Desktop.
Save moziauddin/75fa4a8057f53cc228fe709d80d589e6 to your computer and use it in GitHub Desktop.
Powershell Day to Day Usage Commands
$VerNumber = '1.2.16'
# Search recursively
Get-ChildItem -Recurse | Select-String -Pattern "some-string-to-search" | group path | select name
# Replace string value in a file
((Get-Content -Path .\Temp\Template.wxs -Raw) -replace '1.2.15.1', $VerNumber) | Set-Content -Path .\Temp\Template.wxs
$VerNumber='1.2.15.2'
Remove-Item .\Temp -Recurse -ErrorAction SilentlyContinue
New-Item .\Temp -Type Directory
$input = Read-Host "Enter an option: `n1 for Release`n2 for Debug "
if ($input -eq '1'){
Write-Output "You Picked 1"
Copy-Item "C:\Users\Ziauddin Mohammad\Desktop\ESFA\Tools\Wix-MSI-Builder-Release\*" .\Temp\ -Verbose -Recurse
((Get-Content -Path .\Temp\Template.wxs -Raw) -replace '1.2.15.1', $VerNumber) | Set-Content -Path .\Temp\Template.wxs
# Get-Content .\Temp\Template.wxs
Copy-Item -Recurse -Path .\CordovaApp*\* -Destination .\Temp\
} elseif ($input -eq '2') {
Write-Output "You entered 2"
Copy-Item "C:\Users\Ziauddin Mohammad\Desktop\ESFA\Tools\Wix-MSI-Builder-Debug\*" .\Temp\ -Verbose -Recurse
((Get-Content -Path .\Temp\Template.wxs -Raw) -replace '1.2.15.1', $VerNumber) | Set-Content -Path .\Temp\Template.wxs
# Get-Content .\Temp\Template.wxs
Copy-Item -Recurse -Path .\CordovaApp*\* -Destination .\Temp\
} else {
Write-Output "Please enter '1' or '2' only. Try again. "
Exit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment