gosh
gosh copied to clipboard
Passing a go variable to powershell command
Hello, I have a powershell command that returns some value which assigned to a go variable. Is it possible to use thus go variable in a different powershell command?
err, uninstallString, errout := gosh.PowershellOutput(`$global:ProgressPreference = 'SilentlyContinue'; $WarningPreference = 'SilentlyContinue'; Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_ -match "osquery" } | Select-Object UninstallString`)
I have another powershell command which need uninstallString data to work:
$oldOsqueryID = foreach ($uninstallKey in $uninstallString) { Get-ChildItem -Path $uninstallKey -ErrorAction SilentlyContinue | Where {$_.PSChildName -match '^{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}$'} | Select-Object @{n='GUID';e={$_.PSChildName}}, @{n='Name'; e={$_.GetValue('DisplayName')}} | Where-Object { $_.Name -eq "osquery"} | Select-Object -ExpandProperty GUID }
Is this achievable?
Hi @hexclann, I'm sorry for not replying to you in a while, yes I this is achievable, I will try to add it and test it