Accessing Windows Credential Manager from PowerShell

In powershell5 type: Install-Module CredentialManager -force Then New-StoredCredential -Target $url -Username $ENV:Username -Pass …. and later Get-StoredCredential -Target …. Source code for the module is https://github.com/davotronic5000/PowerShell_Credential_Manager == EDIT 2023 == Original is archived, install newer fork with: Install-Module -Name TUN.CredentialManager Check out Github repository for more details.

How to capture multiple regex matches, from a single line, into the $matches magic variable in Powershell?

You can do this using Select-String in PowerShell 2.0 like so: Select-String F\d\d -input $string -AllMatches | Foreach {$_.matches} A while back I had asked for a -matchall operator on MS Connect and this suggestion was closed as fixed with this comment: “This is fixed with -allmatches parameter for select-string.”

How to export data to CSV in PowerShell?

This solution creates a psobject and adds each object to an array, it then creates the csv by piping the contents of the array through Export-CSV. $results = @() foreach ($computer in $computerlist) { if((Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) { foreach ($file in $REMOVE) { Remove-Item “\\$computer\$DESTINATION\$file” -Recurse Copy-Item E:\Code\powershell\shortcuts\* … Read more

Unblock a file with PowerShell?

If you are using PowerShell v3, you can use the Unblock-File cmdlet. The “blocking” part is simply an alternate data stream of the file, named “Zone.Identifier”. You can display it in CMD by using input redirection (no other way to get to a stream in CMD, though): H:\Downloads> more < test.exe:Zone.Identifier [ZoneTransfer] ZoneId=3 You can … Read more

PowerShell, Web Requests, and Proxies

Somewhat better is the following, which handles auto-detected proxies as well: $proxy = [System.Net.WebRequest]::GetSystemWebProxy() $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials $wc = new-object system.net.WebClient $wc.proxy = $proxy $webpage = $wc.DownloadData($url) (edit) Further to the above, this definition appears to work fine for me, too: function Get-Webclient { $wc = New-Object Net.WebClient $wc.UseDefaultCredentials = $true $wc.Proxy.Credentials = $wc.Credentials $wc … Read more