Skip to content

Commit

Permalink
Fixed issue #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayyhem committed Jan 31, 2024
1 parent f936693 commit 9161812
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/SmsProviderWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,19 @@ public static ManagementObject NewCollectionMember(ManagementScope wmiConnection
{
Thread.Sleep(millisecondsTimeout: 5000);
ManagementObjectCollection collectionMembers = GetCollectionMembers(wmiConnection, collectionName, collectionId);
if (collectionMembers.Count == 1)
if (collectionMembers.Count > 0)
{
Console.WriteLine($"[+] Successfully added {matchingResource["Name"]} {matchingResource["ResourceID"]} to {(!string.IsNullOrEmpty(collectionName) ? collectionName : collectionId)}");
memberAvailable = true;
collectionMember = collectionMembers.Cast<ManagementObject>().First();
foreach (ManagementObject member in collectionMembers)
{
if ((!string.IsNullOrEmpty(deviceName) && (string)member.GetPropertyValue("Name") == deviceName) ||
(!string.IsNullOrEmpty(userName) && member.GetPropertyValue("Name").ToString().Contains(userName)) ||
(!string.IsNullOrEmpty(resourceId) && (uint)member.GetPropertyValue("ResourceID") == Convert.ToUInt32(resourceId)))
{
Console.WriteLine($"[+] Successfully added {matchingResource["Name"]} ({matchingResource["ResourceID"]}) to {(!string.IsNullOrEmpty(collectionName) ? collectionName : collectionId)}");
memberAvailable = true;
collectionMember = collectionMembers.Cast<ManagementObject>().First();
}
}
}
else
{
Expand Down

0 comments on commit 9161812

Please sign in to comment.