powershell

powershell core error: The specified module 'RPC-Client' was not loaded

╄→尐↘猪︶ㄣ 提交于 2021-02-05 08:53:05
问题 How do I find out more information about xml-rpc for powershell ? PS /home/nicholas> PS /home/nicholas> Update-Help PS /home/nicholas> PS /home/nicholas> Get-Help Send-XmlRpcRequest Get-Help: Get-Help could not find Send-XmlRpcRequest in a help file in this session. To download updated help topics type: "Update-Help". To get help online, search for the help topic in the TechNet library at https://go.microsoft.com/fwlink/?LinkID=107116. PS /home/nicholas> PS /home/nicholas> Get-Host | Select

Define Powershell variable to have a value of a list

做~自己de王妃 提交于 2021-02-05 08:42:17
问题 I have some variables as below: $a = "string1" $b = "string2" $c = "string3" Now i want to define a variable $list to with all of the content from $a,$b,$c to look like this: $list = " a: string1 b: string2 c: string3 " how can i do that? *** Edit: the content of the list must be EXACT like i wrote, that means, the part like "a: " b: ", ... must be the same too 回答1: Looks like you don't want an actual list, but a string with a listing of variables. A multiline string with the names and values

Create WMI class and add static property or default value

喜欢而已 提交于 2021-02-05 08:29:05
问题 I'm trying to create a WMI class and add a static property, or set the default value of the property $WMI_Class = New-Object System.Management.ManagementClass("root\default", $null, $null) $WMI_Class.Qualifiers.Add("Static", $true) $WMI_Class.Properties.Add("ver", [System.Management.CimType]::String, "myDefaultValue") $WMI_Class.name = "MyCoreClass" $WMI_Class.Put() $obj = ([WmiClass] 'root\default:MyCoreClass') $ver = $obj.Properties['ver'].Value $ver The class is created but the $ver is

Powershell script to find applications that come with their own Java versions

佐手、 提交于 2021-02-05 08:26:27
问题 I am looking for a way to find out from all installed applications, one that comes with its own java version. There are scripts online to see the version installed on PCs but not the one to get the applications that uses Java and what versions of java they have. I found something close with using system explorer where I can view all running processes but what i want is a script that can find such applications with the java versions they use and then export the result as csv file or something.

Forcing certain code to always run on the same thread

时间秒杀一切 提交于 2021-02-05 08:21:06
问题 We have an old 3rd party system (let's call it Junksoft® 95) that we interface with via PowerShell (it exposes a COM object) and I'm in the process of wrapping it in a REST API (ASP.NET Framework 4.8 and WebAPI 2). I use the System.Management.Automation nuget package to create a PowerShell in which I instantiate Junksoft's COM API as a dynamic object that I then use: //I'm omitting some exception handling and maintenance code for brevity powerShell = System.Management.Automation.PowerShell

Powershell escape for variables that contain passwords

你说的曾经没有我的故事 提交于 2021-02-05 08:19:26
问题 So I am using a variable that contains a password and just recently found out that some of the passwords are containing special characters. I have no control over what the password is so I have to deal with whatever I am getting. I know the back tick '`' character is what is used to escape characters. The whole reason for this post is that I am finding passwords is text files and replacing the found password with a pattern of 'xxxxxxxxx'. Currently the code I am using is this: $pass = "DR

Powershell escape for variables that contain passwords

不羁的心 提交于 2021-02-05 08:19:06
问题 So I am using a variable that contains a password and just recently found out that some of the passwords are containing special characters. I have no control over what the password is so I have to deal with whatever I am getting. I know the back tick '`' character is what is used to escape characters. The whole reason for this post is that I am finding passwords is text files and replacing the found password with a pattern of 'xxxxxxxxx'. Currently the code I am using is this: $pass = "DR

Powershell regex for string between two special characters

孤人 提交于 2021-02-05 08:08:34
问题 A file name as below $inpFiledev = "abc_XYZ.bak" I need only XYZ in a variable to do a compare with other file name. i tried below: [String]$findev = [regex]::match($inpFiledev ,'_*.').Value Write-Host $findev 回答1: Asterisks in regex don't behave in the same way as they do in filesystem listing commands. As it stands your regex is looking for underscore, repeated zero or more times, followed by any character (represented in regex by a period). So the regex finds zero underscores right at the

Powershell regex for string between two special characters

大憨熊 提交于 2021-02-05 08:08:10
问题 A file name as below $inpFiledev = "abc_XYZ.bak" I need only XYZ in a variable to do a compare with other file name. i tried below: [String]$findev = [regex]::match($inpFiledev ,'_*.').Value Write-Host $findev 回答1: Asterisks in regex don't behave in the same way as they do in filesystem listing commands. As it stands your regex is looking for underscore, repeated zero or more times, followed by any character (represented in regex by a period). So the regex finds zero underscores right at the

powershell xml select attribute value where clause

折月煮酒 提交于 2021-02-05 07:57:06
问题 I have a xml file with the following elements: <telecom use="HP" value="tel:+1-512-555-1212" /> <telecom use="WP" value="tel:+1-512-123-4567" /> this returns the value of the first node: $qrda.ClinicalDocument.recordTarget.patientRole.telecom[0].value However I need to be able to return the node where use="HP" and I'm not certain they'll always be in the correct order. Any help is much appreciated. 回答1: The non-XPATH method: ($qrda.ClinicalDocument.recordTarget.patientRole.telecom | Where {$_