Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ internal void NewCimSession(NewCimSessionCommand cmdlet,
CimTestCimSessionContext context = new(proxy, wrapper);
proxy.ContextObject = context;
// Skip test the connection if user intend to
if (cmdlet.SkipTestConnection.IsPresent)
if (cmdlet.SkipTestConnection)
{
AddSessionToCache(proxy.CimSession, context, new CmdletOperationBase(cmdlet));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ private void EnablePSSemantics()
/// </summary>
public SwitchParameter KeyOnly
{
set { this.OperationOptions.KeysOnly = value.IsPresent; }
set { this.OperationOptions.KeysOnly = value; }
}

/// <summary>
Expand All @@ -664,7 +664,7 @@ public SwitchParameter Shallow
{
set
{
if (value.IsPresent)
if (value)
{
this.OperationOptions.Flags = CimOperationFlags.PolymorphismShallow;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected override void BeginProcessing()
//
SetOutputFormat();

if (Circular.IsPresent && _maxSize == 0)
if (Circular && _maxSize == 0)
{
string msg = string.Format(CultureInfo.InvariantCulture, _resourceMgr.GetString("CounterCircularNoMaxSize"));
Exception exc = new Exception(msg);
Expand Down Expand Up @@ -255,7 +255,7 @@ protected override void ProcessRecord()
ReportPdhError(res, true);
}

res = _pdhHelper.OpenLogForWriting(_resolvedPath, _outputFormat, Force.IsPresent, _maxSize * 1024 * 1024, Circular.IsPresent, null);
res = _pdhHelper.OpenLogForWriting(_resolvedPath, _outputFormat, Force, _maxSize * 1024 * 1024, Circular, null);
if (res == PdhResults.PDH_FILE_ALREADY_EXISTS)
{
string msg = string.Format(CultureInfo.InvariantCulture, _resourceMgr.GetString("CounterFileExists"), _resolvedPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected override void BeginProcessing()
return;
}

if (Continuous.IsPresent && _maxSamplesSpecified)
if (Continuous && _maxSamplesSpecified)
{
Exception exc = new(string.Format(CultureInfo.CurrentCulture, _resourceMgr.GetString("CounterContinuousOrMaxSamples")));
ThrowTerminatingError(new ErrorRecord(exc, "CounterContinuousOrMaxSamples", ErrorCategory.InvalidArgument, null));
Expand Down Expand Up @@ -488,7 +488,7 @@ private void ProcessGetCounter()
bool bSkip = true;
uint sampleReads = 0;

if (Continuous.IsPresent)
if (Continuous)
{
_maxSamples = KEEP_ON_SAMPLING;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private void ProcessListLog()
//
// Skip direct channels matching the wildcard unless -Force is present.
//
if (!Force.IsPresent &&
if (!Force &&
WildcardPattern.ContainsWildcardCharacters(logPattern) &&
(logObj.LogType == EventLogType.Debug ||
logObj.LogType == EventLogType.Analytical))
Expand Down Expand Up @@ -624,7 +624,7 @@ private void ProcessFilterXml()
{
using (EventLogSession eventLogSession = CreateSession())
{
if (!Oldest.IsPresent)
if (!Oldest)
{
//
// Do minimal parsing of xmlQuery to determine if any direct channels or ETL files are in it.
Expand Down Expand Up @@ -1544,7 +1544,7 @@ private void CheckHashTableForQueryPathPresence(Hashtable hash)
//
private void TerminateForNonEvtxFileWithoutOldest(string fileName)
{
if (!Oldest.IsPresent)
if (!Oldest)
{
if (System.IO.Path.GetExtension(fileName).Equals(".etl", StringComparison.OrdinalIgnoreCase) ||
System.IO.Path.GetExtension(fileName).Equals(".evt", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -1584,7 +1584,7 @@ private bool ValidateLogName(string logName, EventLogSession eventLogSession)
return false;
}

if (!Oldest.IsPresent)
if (!Oldest)
{
if (logObj.LogType == EventLogType.Debug || logObj.LogType == EventLogType.Analytical)
{
Expand Down Expand Up @@ -1896,7 +1896,7 @@ private void AddLogsForProviderToInternalMap(EventLogSession eventLogSession, st
EventLogConfiguration logObj = new(logLink.LogName, eventLogSession);
if (logObj.LogType == EventLogType.Debug || logObj.LogType == EventLogType.Analytical)
{
if (!Force.IsPresent)
if (!Force)
{
continue;
}
Expand Down Expand Up @@ -1988,7 +1988,7 @@ private void FindLogNamesMatchingWildcards(EventLogSession eventLogSession, IEnu

if (logObj.LogType == EventLogType.Debug || logObj.LogType == EventLogType.Analytical)
{
if (WildcardPattern.ContainsWildcardCharacters(logPattern) && !Force.IsPresent)
if (WildcardPattern.ContainsWildcardCharacters(logPattern) && !Force)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private StartableJob DoCreateQueryJob(TSession sessionForJob, QueryBuilder query
queryJob.SuppressOutputForwarding = true;
}

bool discardNonPipelineResults = (actionAgainstResults != null) || !this.AsJob.IsPresent;
bool discardNonPipelineResults = (actionAgainstResults != null) || !this.AsJob;
HandleJobOutput(
queryJob,
sessionForJob,
Expand Down Expand Up @@ -225,7 +225,7 @@ private StartableJob DoCreateStaticMethodInvocationJob(TSession sessionForJob, M

if (methodInvocationJob != null)
{
bool discardNonPipelineResults = !this.AsJob.IsPresent;
bool discardNonPipelineResults = !this.AsJob;
HandleJobOutput(
methodInvocationJob,
sessionForJob,
Expand Down Expand Up @@ -379,7 +379,7 @@ public override void ProcessRecord(QueryBuilder query)
StartableJob childJob = this.DoCreateQueryJob(sessionForJob, query, actionAgainstResults: null);
if (childJob != null)
{
if (!this.AsJob.IsPresent)
if (!this.AsJob)
{
_parentJob.AddChildJobAndPotentiallyBlock(this.Cmdlet, childJob, ThrottlingJob.ChildJobFlags.None);
}
Expand Down Expand Up @@ -416,7 +416,7 @@ public override void ProcessRecord(QueryBuilder query, MethodInvocationInfo meth
objectInstance,
methodInvocationInfo,
passThru,
closureOverAsJob.IsPresent);
closureOverAsJob);

if (methodInvocationJob != null)
{
Expand All @@ -426,7 +426,7 @@ public override void ProcessRecord(QueryBuilder query, MethodInvocationInfo meth

if (queryJob != null)
{
if (!this.AsJob.IsPresent)
if (!this.AsJob)
{
_parentJob.AddChildJobAndPotentiallyBlock(this.Cmdlet, queryJob, ThrottlingJob.ChildJobFlags.CreatesChildJobs);
}
Expand Down Expand Up @@ -583,10 +583,10 @@ public override void ProcessRecord(TObjectInstance objectInstance, MethodInvocat

foreach (TSession sessionForJob in this.GetSessionsToActAgainst(objectInstance))
{
StartableJob childJob = this.DoCreateInstanceMethodInvocationJob(sessionForJob, objectInstance, methodInvocationInfo, passThru, this.AsJob.IsPresent);
StartableJob childJob = this.DoCreateInstanceMethodInvocationJob(sessionForJob, objectInstance, methodInvocationInfo, passThru, this.AsJob);
if (childJob != null)
{
if (!this.AsJob.IsPresent)
if (!this.AsJob)
{
_parentJob.AddChildJobAndPotentiallyBlock(this.Cmdlet, childJob, ThrottlingJob.ChildJobFlags.None);
}
Expand All @@ -611,7 +611,7 @@ public override void ProcessRecord(MethodInvocationInfo methodInvocationInfo)
StartableJob childJob = this.DoCreateStaticMethodInvocationJob(sessionForJob, methodInvocationInfo);
if (childJob != null)
{
if (!this.AsJob.IsPresent)
if (!this.AsJob)
{
_parentJob.AddChildJobAndPotentiallyBlock(this.Cmdlet, childJob, ThrottlingJob.ChildJobFlags.None);
}
Expand All @@ -628,15 +628,15 @@ public override void ProcessRecord(MethodInvocationInfo methodInvocationInfo)
/// </summary>
public override void BeginProcessing()
{
if (this.AsJob.IsPresent)
if (this.AsJob)
{
MshCommandRuntime commandRuntime = (MshCommandRuntime)this.Cmdlet.CommandRuntime; // PSCmdlet.CommandRuntime is always MshCommandRuntime
string conflictingParameter = null;
if (commandRuntime.WhatIf.IsPresent)
if (commandRuntime.WhatIf)
{
conflictingParameter = "WhatIf";
}
else if (commandRuntime.Confirm.IsPresent)
else if (commandRuntime.Confirm)
{
conflictingParameter = "Confirm";
}
Expand All @@ -656,7 +656,7 @@ public override void BeginProcessing()
jobName: this.GenerateParentJobName(),
jobTypeName: CIMJobType,
maximumConcurrentChildJobs: this.ThrottleLimit,
cmdletMode: !this.AsJob.IsPresent);
cmdletMode: !this.AsJob);
}

/// <summary>
Expand All @@ -665,7 +665,7 @@ public override void BeginProcessing()
public override void EndProcessing()
{
_parentJob.EndOfChildJobs();
if (this.AsJob.IsPresent)
if (this.AsJob)
{
this.Cmdlet.WriteObject(_parentJob);
this.Cmdlet.JobRepository.Add(_parentJob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ public void Dispose()
protected override void ProcessRecord()
{
object[] flags = new object[] { 1, 0 };
if (Force.IsPresent)
if (Force)
flags[0] = forcedShutdown;

ProcessWSManProtocol(flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected override void BeginProcessing()
}
else
{
if (List.IsPresent)
if (List)
{
if (!this.ValidateClassFormat())
{
Expand All @@ -230,7 +230,7 @@ protected override void BeginProcessing()

foreach (string name in ComputerName)
{
if (this.Recurse.IsPresent)
if (this.Recurse)
{
Queue namespaceElement = new Queue();
namespaceElement.Enqueue(this.Namespace);
Expand Down Expand Up @@ -349,7 +349,7 @@ protected override void BeginProcessing()
}

// When -List is not specified and -Recurse is specified, we need the -Class parameter to compose the right query string
if (this.Recurse.IsPresent && string.IsNullOrEmpty(Class))
if (this.Recurse && string.IsNullOrEmpty(Class))
{
string errorMsg = string.Format(CultureInfo.InvariantCulture, WmiResources.WmiParameterMissing, "-Class");
ErrorRecord er = new ErrorRecord(new InvalidOperationException(errorMsg), "InvalidOperationException", ErrorCategory.InvalidOperation, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ protected override void ProcessRecord()
{
foreach (Process process in MatchingProcesses())
{
if (Module.IsPresent && FileVersionInfo.IsPresent)
if (Module && FileVersionInfo)
{
ProcessModule tempmodule = null;
try
Expand Down Expand Up @@ -594,7 +594,7 @@ protected override void ProcessRecord()
WriteNonTerminatingError(process, exception, ProcessResources.CouldNotEnumerateModuleFileVer, "CouldNotEnumerateModuleFileVer", ErrorCategory.PermissionDenied);
}
}
else if (Module.IsPresent)
else if (Module)
{
try
{
Expand Down Expand Up @@ -627,7 +627,7 @@ protected override void ProcessRecord()
WriteNonTerminatingError(process, exception, ProcessResources.CouldNotEnumerateModules, "CouldNotEnumerateModules", ErrorCategory.PermissionDenied);
}
}
else if (FileVersionInfo.IsPresent)
else if (FileVersionInfo)
{
try
{
Expand Down Expand Up @@ -670,7 +670,7 @@ protected override void ProcessRecord()
}
else
{
WriteObject(IncludeUserName.IsPresent ? AddUserNameToProcess(process) : process);
WriteObject(IncludeUserName ? AddUserNameToProcess(process) : process);
}
}
}
Expand Down Expand Up @@ -2131,7 +2131,7 @@ protected override void BeginProcessing()
#endif
}

if (PassThru.IsPresent)
if (PassThru)
{
if (process != null)
{
Expand All @@ -2145,7 +2145,7 @@ protected override void BeginProcessing()
}
}

if (Wait.IsPresent)
if (Wait)
{
if (process != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,21 @@ protected override void ProcessRecord()
{
foreach (ServiceController service in MatchingServices())
{
if (!DependentServices.IsPresent && !RequiredServices.IsPresent)
if (!DependentServices && !RequiredServices)
{
WriteObject(AddProperties(scManagerHandle, service));
}
else
{
if (DependentServices.IsPresent)
if (DependentServices)
{
foreach (ServiceController dependantserv in service.DependentServices)
{
WriteObject(dependantserv);
}
}

if (RequiredServices.IsPresent)
if (RequiredServices)
{
foreach (ServiceController servicedependedon in service.ServicesDependedOn)
{
Expand Down Expand Up @@ -1932,7 +1932,7 @@ protected override void ProcessRecord()
SetServiceSecurityDescriptor(service, SecurityDescriptorSddl, hService);
}

if (PassThru.IsPresent)
if (PassThru)
{
// To display the service, refreshing the service would not show the display name after updating
ServiceController displayservice = new(Name);
Expand Down
Loading