powershell

Unable to “Import Certificate” using API in PowerShell

亡梦爱人 提交于 2021-02-08 10:42:25
问题 I have a self signed certificate that I am trying to import to Azure Key Vault Certificate, and I am facing issues. I am not doing it using the Import-AzKeyVaultCertificate command, but using the API. I was successfully able to create a Key via the API route, but for the life of me, I am not able to Import a certificate. FYI, it also works when I do it over an Azure DevOps pipeline, so I know the Service Principle isn't the issue. Here's how I am creating the certificate (over PowerShell

Move files after upload using PowerShell/WinSCP Script

无人久伴 提交于 2021-02-08 10:35:14
问题 I am using a PowerShell script generated in WinSCP to sftp files in a certain folder. It runs every Friday morning, but I need it to move the files to another folder after they are uploaded. I tried the MoveFiles and PutFiles command but they don't seem to work. Any help is appreciated. Code below. # Load WinSCP .NET assembly Add-Type -Path "WinSCPnet.dll" # Set up session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName =

Powershell reading multiple variables from text file

孤街浪徒 提交于 2021-02-08 10:20:27
问题 I'm quite new to PS, so please don't kill me if the resolution is so easy :) I've tried to find a solution here and in google, but no luck. This is part of code which don't work as I want $Contents = Get-Content "Path\test.txt" foreach($Line in $Contents) { $Line = $Line.split(":")[1] $s = $line -split ':' $RegPath = $s[0] $Value_Name = $s[1] $Type = $s[2] $Value = $s[3] Write-host $RegPath $Value_Name $Type $Value } The output from Write-Host is ok, but the main problem is when I want to use

Powershell reading multiple variables from text file

拈花ヽ惹草 提交于 2021-02-08 10:20:16
问题 I'm quite new to PS, so please don't kill me if the resolution is so easy :) I've tried to find a solution here and in google, but no luck. This is part of code which don't work as I want $Contents = Get-Content "Path\test.txt" foreach($Line in $Contents) { $Line = $Line.split(":")[1] $s = $line -split ':' $RegPath = $s[0] $Value_Name = $s[1] $Type = $s[2] $Value = $s[3] Write-host $RegPath $Value_Name $Type $Value } The output from Write-Host is ok, but the main problem is when I want to use

How to save Powershell output to specific folder on the local machine when running an Invoke command on remote machine

浪尽此生 提交于 2021-02-08 10:06:14
问题 I am using powershell to pull basic computer information from all computers on a LAN. These computers are not, and will never be on, a domain. I have had some success in my test runs getting the output for all of the machines to save into the c:\scripts folder on the host machine. I am, however, having to use the Invoke-command for every cmdlet so that I can put the Output destination outside of the {}. $computers = Get-Content -Path 'c:\scripts\livePCs.txt' foreach ($computer in $computers)

How to save Powershell output to specific folder on the local machine when running an Invoke command on remote machine

坚强是说给别人听的谎言 提交于 2021-02-08 10:05:07
问题 I am using powershell to pull basic computer information from all computers on a LAN. These computers are not, and will never be on, a domain. I have had some success in my test runs getting the output for all of the machines to save into the c:\scripts folder on the host machine. I am, however, having to use the Invoke-command for every cmdlet so that I can put the Output destination outside of the {}. $computers = Get-Content -Path 'c:\scripts\livePCs.txt' foreach ($computer in $computers)

Force Powershell function to return Array [duplicate]

你。 提交于 2021-02-08 09:56:50
问题 This question already has answers here : Return array with single element in PowerShell (2 answers) How do I force a function to return a single element array instead of the contained object? (2 answers) How can I force Powershell to return an array when a call only returns one object? (7 answers) Closed 1 year ago . How can i force a Powershell function to return an Array? This simple function for Example, if "C:\New folder" contains only 1 element, it will not return an Array. function Get

git filter repo - Python was not found - but it's installed

二次信任 提交于 2021-02-08 09:54:42
问题 So I'm trying to use git filter-repo for the first time. I've installed Python 3.9. I try to run: git filter-repo --strip-blobs-bigger-than 100M Each time it fails: Git Bash: git: 'filter-repo' is not a git command. Powershell: Python was not found; CMD: Python was not found; Any advice on what I'm missing please? 回答1: Double-check the installation process on newren/git-filter-repo/INSTALL You must make sure first (in a regular CMD) than git-filter-repo is in your %PATH% . If you install it

git filter repo - Python was not found - but it's installed

北慕城南 提交于 2021-02-08 09:54:42
问题 So I'm trying to use git filter-repo for the first time. I've installed Python 3.9. I try to run: git filter-repo --strip-blobs-bigger-than 100M Each time it fails: Git Bash: git: 'filter-repo' is not a git command. Powershell: Python was not found; CMD: Python was not found; Any advice on what I'm missing please? 回答1: Double-check the installation process on newren/git-filter-repo/INSTALL You must make sure first (in a regular CMD) than git-filter-repo is in your %PATH% . If you install it

git filter repo - Python was not found - but it's installed

这一生的挚爱 提交于 2021-02-08 09:54:11
问题 So I'm trying to use git filter-repo for the first time. I've installed Python 3.9. I try to run: git filter-repo --strip-blobs-bigger-than 100M Each time it fails: Git Bash: git: 'filter-repo' is not a git command. Powershell: Python was not found; CMD: Python was not found; Any advice on what I'm missing please? 回答1: Double-check the installation process on newren/git-filter-repo/INSTALL You must make sure first (in a regular CMD) than git-filter-repo is in your %PATH% . If you install it