powershell-v5.1

Update zipfiles with PowerShell 5 or >. Working code looking for improvement

时光毁灭记忆、已成空白 提交于 2020-05-16 04:08:28
问题 Windows 10 64-bit. PowerShell 5.1 Update zipfiles with PowerShell 5 or >. Working code looking for improvement. 1.1.txt, 1.1.3.txt and 1.txt go in FileGroup0000000001.zip 11.txt and 11.1.txt goes in FileGroup0000000011.zip 2.1.3.6.txt, 2.1.3.6.7.txt, 2.1.txt, and 2.txt go in FileGroup0000000002.zip Update zipfiles with PowerShell 5 gci, regex, $Matches, foreach {$_ PadLeft}, Compress-Archive, and Remove-Item . Avg 29ms 9 files (48KB) 3 archives on ten runs. For testing clear your desktop.

Update zipfiles with PowerShell 5 or >. Working code looking for improvement

落花浮王杯 提交于 2020-05-16 04:05:56
问题 Windows 10 64-bit. PowerShell 5.1 Update zipfiles with PowerShell 5 or >. Working code looking for improvement. 1.1.txt, 1.1.3.txt and 1.txt go in FileGroup0000000001.zip 11.txt and 11.1.txt goes in FileGroup0000000011.zip 2.1.3.6.txt, 2.1.3.6.7.txt, 2.1.txt, and 2.txt go in FileGroup0000000002.zip Update zipfiles with PowerShell 5 gci, regex, $Matches, foreach {$_ PadLeft}, Compress-Archive, and Remove-Item . Avg 29ms 9 files (48KB) 3 archives on ten runs. For testing clear your desktop.

Update zipfiles with PowerShell 5 or >. Working code looking for improvement

[亡魂溺海] 提交于 2020-05-16 04:05:31
问题 Windows 10 64-bit. PowerShell 5.1 Update zipfiles with PowerShell 5 or >. Working code looking for improvement. 1.1.txt, 1.1.3.txt and 1.txt go in FileGroup0000000001.zip 11.txt and 11.1.txt goes in FileGroup0000000011.zip 2.1.3.6.txt, 2.1.3.6.7.txt, 2.1.txt, and 2.txt go in FileGroup0000000002.zip Update zipfiles with PowerShell 5 gci, regex, $Matches, foreach {$_ PadLeft}, Compress-Archive, and Remove-Item . Avg 29ms 9 files (48KB) 3 archives on ten runs. For testing clear your desktop.

Using Format Operator within Replace Operator in PowerShell [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-25 01:36:04
问题 This question already has answers here : Use a function in Powershell replace (2 answers) Closed 12 months ago . I'm trying to rename my files "Introduction _ C# _ Tutorial 1" to something like "01.Introduction" . It needs a -replace operator as well as a -f operator to zero pad the index number. My code is like: $string = "Introduction _ C# _ Tutorial 1" if ($string -match "^([^_]+)_[^\d]+(\d{1,2})$") { $Matches[0] -replace "^([^_]+) _[^\d]+(\d{1,2})$", ("{0:d2}. {1}" -f '$2', '$1') } The

What type of object is $<drivename>: (such as `$code:`) in Powershell?

非 Y 不嫁゛ 提交于 2019-12-18 07:12:19
问题 I was using tab autocompletion for a variable name in Powershell 5.1 today and noticed that one of the choices was the name of a PSDrive. The drive name is docs and I wanted to expand is called $document_name . When I typed $do<tab> , the shell did indeed expand what I had typed to $document_name but for some reason, I typed <tab> a second time and that's when the expanded text changed to $docs: . I explored further and found that this type of variable exists for each of my PSDrives, or at

Property passed to Invoke-Command changes type from IDictionary to HashTable

安稳与你 提交于 2019-12-05 04:03:24
问题 I've been getting an error running Invoke-Command where the script block takes a parameter of type dictionary: Cannot process argument transformation on parameter 'dictionary'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "System.Collections.Generic.IDictionary`2[System.String,System.String]". At line:7 char:1 + Invoke-Command -ComputerName . -ArgumentList $dictionary -ScriptBlock ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Property passed to Invoke-Command changes type from IDictionary to HashTable

跟風遠走 提交于 2019-12-03 20:45:52
I've been getting an error running Invoke-Command where the script block takes a parameter of type dictionary: Cannot process argument transformation on parameter 'dictionary'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "System.Collections.Generic.IDictionary`2[System.String,System.String]". At line:7 char:1 + Invoke-Command -ComputerName . -ArgumentList $dictionary -ScriptBlock ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [], ParameterBindin...mationException +