Skip to content

Commit

Permalink
Fixed exec --wait-time default
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayyhem committed Nov 7, 2023
1 parent 836b67a commit b4d6578
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void Main(string[] args)
execCommand.Add(new Option<string>(new[] { "--user", "-u" }, "The UniqueUserName of the user to execute an application as or receive NTLM authentication from (e.g., \"APERTURE\\cave.johnson\")"));
execCommand.Add(new Option<string>(new[] { "--site-code", "-sc" }, "The three character site code (e.g., \"PS1\") (default: the site code of the client running SharpSCCM)"));
execCommand.Add(new Option<string>(new[] { "--sms-provider", "-sms" }, "The IP address, FQDN, or NetBIOS name of the SMS Provider to connect to (default: the current management point of the client running SharpSCCM)"));
execCommand.Add(new Option<int>(new[] { "--wait-time", "-w" }, "The time (in seconds) to wait for the deployment to execute before cleaning up (default: 120)"));
execCommand.Add(new Option<int>(new[] { "--wait-time", "-w" }, () => 120, "The time (in seconds) to wait for the deployment to execute before cleaning up (default: 120)"));
execCommand.Handler = CommandHandler.Create(
(string device, string collectionId, string collectionName, string path, string relayServer, string resourceId, bool runAsSystem, string collectionType, string user, int waitTime, string smsProvider, string siteCode) =>
{
Expand All @@ -92,7 +92,7 @@ static void Main(string[] args)
ManagementScope wmiConnection = MgmtUtil.NewWmiConnection(smsProvider, null, siteCode);
if (wmiConnection != null && wmiConnection.IsConnected)
{
SmsProviderWmi.Exec(wmiConnection, collectionId, collectionName, device, path, relayServer, resourceId, !runAsSystem, collectionType, user, waitTime = 120);
SmsProviderWmi.Exec(wmiConnection, collectionId, collectionName, device, path, relayServer, resourceId, !runAsSystem, collectionType, user, waitTime);
}
}
});
Expand Down
8 changes: 6 additions & 2 deletions lib/SmsProviderWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public static class SmsProviderWmi
{
public static void Exec(ManagementScope wmiConnection, string collectionId = null, string collectionName = null, string deviceName = null, string applicationPath = null, string relayServer = null, string resourceId = null, bool runAsUser = true, string collectionType = null, string userName = null, int waitTime = 120)
{
ManagementObject collection = GetCollection(wmiConnection, collectionName, collectionId);
ManagementObject collection = null;
if (!string.IsNullOrEmpty(collectionName) || !string.IsNullOrEmpty(collectionId))
{
collection = GetCollection(wmiConnection, collectionName, collectionId);
}
// Create a collection is one is not specified
if (collection == null)
{
Expand Down Expand Up @@ -1022,7 +1026,7 @@ public static ManagementObject NewCollectionMember(ManagementScope wmiConnection
try
{
collection.InvokeMethod("AddMembershipRule", addMembershipRuleParams, null);
Console.WriteLine($"[+] Added {matchingResource["Name"]} {matchingResource["ResourceID"]} to {(!string.IsNullOrEmpty(collectionName) ? collectionName : collectionId)}");
Console.WriteLine($"[+] Added {matchingResource["Name"]} ({matchingResource["ResourceID"]}) to {(!string.IsNullOrEmpty(collectionName) ? collectionName : collectionId)}");
Console.WriteLine($"[+] Waiting for new collection member to become available...");
bool memberAvailable = false;
while (!memberAvailable)
Expand Down

0 comments on commit b4d6578

Please sign in to comment.