wmi

How do I get an error reason from InstallProductKey (SoftwareLicensingService) in PowerShell?

こ雲淡風輕ζ 提交于 2019-12-20 04:41:13
问题 I'm using some PowerShell functions to configure Windows product keys and activation. I get an instance of the SoftwareLicensingService and call InstallProductKey, like this. The trap block with super formatting is extra to help debugging. trap [Exception] { "==================================================" "Trapped: $($Error[0])" "==================================================" "Exception: $($_.Exception)" "--------------------------------------------------" "" break } $service = Get

How do I get an error reason from InstallProductKey (SoftwareLicensingService) in PowerShell?

我是研究僧i 提交于 2019-12-20 04:41:08
问题 I'm using some PowerShell functions to configure Windows product keys and activation. I get an instance of the SoftwareLicensingService and call InstallProductKey, like this. The trap block with super formatting is extra to help debugging. trap [Exception] { "==================================================" "Trapped: $($Error[0])" "==================================================" "Exception: $($_.Exception)" "--------------------------------------------------" "" break } $service = Get

Methods of programatically altering ipsec rules with C#?

冷暖自知 提交于 2019-12-20 03:13:52
问题 The only method I know how to execute IPsec changes involves calling netsh to do the changes. Is there a method using System.Management and WMI objects directly? If so, what is it? I am having a hard time finding relevant WMI information with MSDN. Or is there some other useful method someone out there has used? EDIT: I am working in C#, and would prefer C# examples with regard to .NET System.Management based answers. Thank you! 回答1: 1) Exact: WMI. The EnableIPFilterSec WMI class static

availability of Win32_MountPoint and Win32_Volume on Windows XP?

。_饼干妹妹 提交于 2019-12-20 02:38:21
问题 From the MSDN articles I've found -- http://msdn.microsoft.com/en-us/library/aa394515(v=VS.85).aspx -- Win32_Volume and Win32_MountPoint aren't available on Windows XP. However, I'm developing a C# app on Windows XP (64bit), and I can get to those WMI classes just fine. Users of my app will be on Windows XP sp2 with .Net 3.5 sp1. Googling around, I can't determine whether I can count on this or not. Am I successful on my system because of one or more of the following: - windows xp service

Why is enumerating installed MSI packages so slow?

余生颓废 提交于 2019-12-20 02:13:24
问题 This is a follow up from this question. I'm using this slightly modified script to enumerate all installed MSI packages: strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & _ strComputer & _ "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Product") If colSoftware.Count > 0 Then For Each objSoftware in colSoftware WScript.Echo objSoftware.Caption & vbtab & _ objSoftware.Version Next Else WScript.Echo "Cannot

Why is enumerating installed MSI packages so slow?

陌路散爱 提交于 2019-12-20 02:13:05
问题 This is a follow up from this question. I'm using this slightly modified script to enumerate all installed MSI packages: strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & _ strComputer & _ "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Product") If colSoftware.Count > 0 Then For Each objSoftware in colSoftware WScript.Echo objSoftware.Caption & vbtab & _ objSoftware.Version Next Else WScript.Echo "Cannot

PowerShell: Format Get-WmiObject output to return only the IP address

主宰稳场 提交于 2019-12-19 17:48:53
问题 I would like to use Get-WmiObject Win32_NetworkAdapterConfiguration to return the ip address of a network card. Unfortunately, I cannot figure out how to format the output to display only the IPv.4 address. Get-WmiObject Win32_NetworkAdapterConfiguration | Select IPAddress | Where-Object {$_.IPaddress -like "192.168*"} Displays: IPAddress --------- {192.168.56.1, fe80::8980:15f4:e2f4:aeca} Using the above output as an example, I would like it to only return 192.168.56.1 (Some clients have

How do I escape comma in WMIC inside like string

会有一股神秘感。 提交于 2019-12-19 09:49:40
问题 I wish to be able to run a query like the following: wmic path Win32_Service where "DisplayName like 'FooBarService % (X, Y)'" get * But, it doesn't work because of the comma inside the like string. The error I get is "Invalid Verb." I tried escaping it with a backslash, and I tried escaping it using brackets as underscores are meant to be escaped, and both resulted in the "Invalid Verb." error. As a less-than-ideal workaround, I can replace the commas with underscores, and it works, but the

.NET - Copying an executable across LAN to another computer, and executing it

*爱你&永不变心* 提交于 2019-12-19 08:13:31
问题 I'm using .NET, and going crazy trying to find any helpful API that lets me transfer a file across a LAN network (trough admin credentials of course) and then execute it on that machine. I've read some thing using WMI, but googling for ".net WMI copy files" or ".net WMI execute files" isn't helping me at all. Any references would be greatly appreciated. EDIT I can't use a third party tool such as PsExec (although it does perfectly what I need). This is because of the license involved with

Create Table with Variables in PowerShell

时间秒杀一切 提交于 2019-12-19 08:06:59
问题 I'm still learning my way around PowerShell scripting and I'm working on a script to calculate the free space percentage of my file servers and send an e-mail notification when a drive reaches 10% of free space remaining or less (this happens roughly once a month, and I need to know before I get e-mailed from client's that there's no more space). As of now the script works great and is set up to run every morning via Windows Task. But the current formatting that I have in place for the output