Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string computer = "Computer_B";
- string domain = "WORKGROUP";
- string username = ".\LocalAdminUserName";
- string plaintextpassword;
- Console.WriteLine("Enter password:");
- plaintextpassword = Console.ReadLine();
- SecureString securepassword = new SecureString();
- foreach (char c in plaintextpassword)
- {
- securepassword.AppendChar(c);
- }
- CimCredential Credentials = new
- CimCredential(PasswordAuthenticationMechanism.Default, domain,
- username,securepassword);
- WSManSessionOptions SessionOptions = new WSManSessionOptions();
- SessionOptions.AddDestinationCredentials(Credentials);
- CimSession Session = CimSession.Create(computer, SessionOptions);
- var allVolumes = Session.QueryInstances(@"rootcimv2", "WQL", "SELECT * FROM Win32_LogicalDisk");
- // Loop through all volumes
- foreach (CimInstance oneVolume in allVolumes)
- {
- Console.Writeline(oneVolume.CimInstanceProperties["SystemName"].Value.ToString());
- }
Add Comment
Please, Sign In to add comment