powershell

How can I remove spaces from this PowerShell array?

£可爱£侵袭症+ 提交于 2021-02-11 15:42:14
问题 I'm trying to get all ASCII numbers and letters from Powershell for use as a key later on. My code so far looks like this: [char[]] $keyArray = @() for($i = 65;$i -le 122;$i++) { if($i -lt 91 -or $i -gt 96) { $keyArray += [char]$i } } for($i = 0; $i -le 9; $i++) { $keyArray += ("$i") } Write-Host [string]$keyArray However, when I write this out (last line), I get the following with spaces in between each character: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m

How can I remove spaces from this PowerShell array?

六眼飞鱼酱① 提交于 2021-02-11 15:41:39
问题 I'm trying to get all ASCII numbers and letters from Powershell for use as a key later on. My code so far looks like this: [char[]] $keyArray = @() for($i = 65;$i -le 122;$i++) { if($i -lt 91 -or $i -gt 96) { $keyArray += [char]$i } } for($i = 0; $i -le 9; $i++) { $keyArray += ("$i") } Write-Host [string]$keyArray However, when I write this out (last line), I get the following with spaces in between each character: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m

Comparing Arrays within Powershell

走远了吗. 提交于 2021-02-11 15:40:40
问题 I'm looking to do the Following Steps: Reading in a CSV File Add The Contents from the CSV File to An Array Compare the Contents from the CSV with the Contents from another Array If the Items in the Array aren't members of the CSV Array Send Email I First Tried Running the Script with One Host Missing from the Reports2 CSV File, This Missing Host was displayed to the Console and Written to the Reports2 File, but Still when i Re-Run the Code it still displays the last Element (Host that was

Comparing Arrays within Powershell

不打扰是莪最后的温柔 提交于 2021-02-11 15:38:06
问题 I'm looking to do the Following Steps: Reading in a CSV File Add The Contents from the CSV File to An Array Compare the Contents from the CSV with the Contents from another Array If the Items in the Array aren't members of the CSV Array Send Email I First Tried Running the Script with One Host Missing from the Reports2 CSV File, This Missing Host was displayed to the Console and Written to the Reports2 File, but Still when i Re-Run the Code it still displays the last Element (Host that was

Powershell question - Looking for fastest method to loop through 500k objects looking for a match in another 500k object array

☆樱花仙子☆ 提交于 2021-02-11 15:34:32
问题 I have two large .csv files that I've imported using the import-csv cmdlet. I've done a lot of searching and trying and am finally posting to ask for some help to make this easier. I need to move through the first array that will have anywhere from 80k rows to 500k rows. Each object in these arrays has multiple properties, and I then need to find the corresponding entry in a second array of the same size matching on a property from there. I'm importing them as [systems.collection.arrayList]

Powershell question - Looking for fastest method to loop through 500k objects looking for a match in another 500k object array

≯℡__Kan透↙ 提交于 2021-02-11 15:33:08
问题 I have two large .csv files that I've imported using the import-csv cmdlet. I've done a lot of searching and trying and am finally posting to ask for some help to make this easier. I need to move through the first array that will have anywhere from 80k rows to 500k rows. Each object in these arrays has multiple properties, and I then need to find the corresponding entry in a second array of the same size matching on a property from there. I'm importing them as [systems.collection.arrayList]

Unable to fetch data using external data source

拜拜、爱过 提交于 2021-02-11 15:23:21
问题 I am trying to fetch values from azure using external data source in terraform. However, i dont understand what am i doing wrong when i try to export values using write-output, getting an error data.external.powershell_test: data.external.powershell_test: command "Powershell.exe" produced invalid JSON: invalid character 'l' looking for beginning of object key string" Below is my script $vm=(Get-AzureRmVM -ResourceGroupName MFA-RG -Name vm2).name | convertTo-json Write-Output "{""first"" : ""

Hello World for Powershell Send-XmlRcpRequest?

柔情痞子 提交于 2021-02-11 15:00:42
问题 Desired output something like: <?xml version="1.0"?> <methodResponse> <params> <param> <value><string>South Dakota</string></value> </param> </params> </methodResponse> How do I use the xml-rpc powershell module to view the response? Perhaps it's possible to "cat" or somehow pipe the result from baidu to something that will print it? Or, put it into an object? PS /home/nicholas/powershell> PS /home/nicholas/powershell> Send-XmlRpcRequest -Url "http://ping.baidu.com/ping/RPC2" -MethodName

PowerShell Az module: export and import offline

只愿长相守 提交于 2021-02-11 14:41:15
问题 I need to move PowerShell Az module from one machine to another offline (both machines have the same windows (10 Pro 1809), .net, powershell (5.1), etc versions) I can't use either Private PowerShellGet Repositories or MSI installer I run Save-Module -Name Az -Path 'C:\Users\kag\Documents\ps_modules' -RequiredVersion 3.7.0 -Force on "donor" machine and it gives me 50+ dirs exported: I copy all to "receiver" machine and running: Get-ChildItem "C:\Users\kag\Documents\ps_modules\*" -Recurse |

Conventions and native support for defining private functions inside a module

不打扰是莪最后的温柔 提交于 2021-02-11 14:29:26
问题 powershell modules make it possible to have private "methods", but I cant find any conventions or support for defining them as such. For larger scripts this is more than just a superficial code prettiness thing, it becomes very important to be able to tell if a method is local or not just by its name. This sort of works but powershell complains every time I import that its not using a properly named verb. Is there a supported prefix for defining local functions/methods? function _Get