wmi

Querying the size of a drive on a remote server is giving me a not found error

爱⌒轻易说出口 提交于 2019-12-24 05:52:20
问题 Here's what I have: public static bool DriveHasLessThanTenPercentFreeSpace(string server) { long driveSize = 0; long freeSpace = 0; var oConn = new ConnectionOptions {Username = "username", Password = Settings.Default.SQLServerAdminPassword}; var scope = new ManagementScope("\\\\" + server + "\\root\\CIMV2", oConn); scope.Connect(); var query = new ObjectQuery("SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID = 'D:'"); var searcher = new ManagementObjectSearcher(scope, query);

Querying the size of a drive on a remote server is giving me a not found error

梦想与她 提交于 2019-12-24 05:52:02
问题 Here's what I have: public static bool DriveHasLessThanTenPercentFreeSpace(string server) { long driveSize = 0; long freeSpace = 0; var oConn = new ConnectionOptions {Username = "username", Password = Settings.Default.SQLServerAdminPassword}; var scope = new ManagementScope("\\\\" + server + "\\root\\CIMV2", oConn); scope.Connect(); var query = new ObjectQuery("SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID = 'D:'"); var searcher = new ManagementObjectSearcher(scope, query);

powershell how to remove `{}@` from output. Is there a special command to do it?

萝らか妹 提交于 2019-12-24 05:05:36
问题 I entered gwmi win32_product | select -property name | select -first 1 and output to a file. My result was @{name=Google Talk Plugin} . How can I get rid of @{} , and name. I only want it to show Google Talk Plugin ? 回答1: @{} means your exporting an object with properties. Try the -ExpandProperty parameter in Select-Object . You could also combine both select-object commands, like: gwmi win32_product | select -expandproperty name -first 1 回答2: I ran into a problem similar with $drive = Get

Is there a method to open CMD as Admin through a C# command?

旧巷老猫 提交于 2019-12-24 05:05:08
问题 I have a small command that allows me to query information from CMD, however it needs admin privileges (not at my application level but at the CMD level) Only reason I am going this route is because I couldn't get WMI to query bitlocker settings for the life of me and this project needs to get off of my desk. if (bitA.Text == "Bitlocker Available") { Process cmd2 = new Process(); cmd2.StartInfo.Verb = "runas"; cmd2.StartInfo.FileName = "cmd.exe"; cmd2.StartInfo.Arguments = "/c ping 8.8.8.8";

Is there a method to open CMD as Admin through a C# command?

南笙酒味 提交于 2019-12-24 05:05:06
问题 I have a small command that allows me to query information from CMD, however it needs admin privileges (not at my application level but at the CMD level) Only reason I am going this route is because I couldn't get WMI to query bitlocker settings for the life of me and this project needs to get off of my desk. if (bitA.Text == "Bitlocker Available") { Process cmd2 = new Process(); cmd2.StartInfo.Verb = "runas"; cmd2.StartInfo.FileName = "cmd.exe"; cmd2.StartInfo.Arguments = "/c ping 8.8.8.8";

Programmatically getting SQL Cluster Virtual Name

送分小仙女□ 提交于 2019-12-24 04:32:21
问题 I have written a Windows service to collect information from all of our SQL servers. The service gets installed onto each server, and utilizing WMI and SMO, inserts relevant system information back to a central database. In order to get the SQL information, I use the following c# code: List<Server> sqlServers = new List<Server>(); //List of Smo.Server objects string registrySubKey = @"SOFTWARE\Microsoft\Microsoft SQL Server"; string registryValue = "InstalledInstances"; try { RegistryKey rk =

How to query Folder Size in remote computer through WMI and C#

穿精又带淫゛_ 提交于 2019-12-24 04:15:08
问题 How to query Folder Size in remote computer through WMI and C#. I need to find the each User's folder size in C:\Users in remote System through WMI. I tried Win32_Directory , CMI_DataFile but not able to find the desired answer. Please help!! 回答1: To get the size of a folder using the WMI, you must iterate over the files using the CIM_DataFile class and then get the size of each file from the FileSize property. Try this sample (this code is not recursive, I leave such task for you). using

web-administration vs WMI to query web directory properties performance problems

戏子无情 提交于 2019-12-24 03:26:00
问题 I have been building a server diff script for IIS and i've found that using the web-administration module is dramatically slower than WMI to get the same information. I built the WMI module first as i am working on a 2003 sunset project yet i found when i started into the IIS7 methods it was extremely slow. Processing time -- IIS7: 348.988, IIS6: 10.309 (seconds) The biggest time loss is in retrieving the properties for each directory under the webapp, this is taking ~5 seconds per 10

Closing an IE instance created by WScript.CreateObject

夙愿已清 提交于 2019-12-24 02:33:19
问题 I'm looking for a way to retrieve the process ID from an object that was created by running: Set ie = WScript.CreateObject("InternetExplorer.Application", "ie_") My problem is that sometimes I see that the iexplorer process remains open and isn't closed after running: ie.stop ie.Quit I found some workarounds, like looking for the newest iexplorer process or looking at the process name, but this isn't good for me since I have several Internet Explorer instances opened in parallel by different

WMI for quering active networks and associate connections

此生再无相见时 提交于 2019-12-24 01:53:17
问题 I need to change Network settings like described in this article. That works good so far. However I also need to know on what active network I make the changes. (For a better understanding please open Control Panel\Network and Internet\ Network and Sharing Center . Unfortunately all picture hosting sites are blocked by my company so I can't post a screenshot.) Any help on how I can query what connection is associated with what network with WMI (or other technology)? UPDATE: I need to query a