-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCCMClient.cs
More file actions
79 lines (71 loc) · 2.21 KB
/
CCMClient.cs
File metadata and controls
79 lines (71 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using PSCCMClient.Core.Services;
namespace PSCCMClient.Core
{
/// <summary>
/// Main client for interacting with Configuration Manager
/// </summary>
public class CCMClient
{
private readonly string _computerName;
/// <summary>
/// Gets the application service for this client
/// </summary>
public CCMApplicationService Applications { get; }
/// <summary>
/// Gets the package service for this client
/// </summary>
public CCMPackageService Packages { get; }
/// <summary>
/// Gets the computer name this client is connected to
/// </summary>
public string ComputerName => _computerName;
/// <summary>
/// Initializes a new CCMClient for the local computer
/// </summary>
public CCMClient() : this(".")
{
}
/// <summary>
/// Initializes a new CCMClient for the specified computer
/// </summary>
/// <param name="computerName">The name of the computer to connect to</param>
public CCMClient(string computerName)
{
_computerName = computerName ?? ".";
Applications = new CCMApplicationService(_computerName);
Packages = new CCMPackageService(_computerName);
}
/// <summary>
/// Tests connectivity to the Configuration Manager client
/// </summary>
/// <returns>True if the client is accessible</returns>
public async Task<bool> TestConnectionAsync()
{
try
{
var apps = await Applications.GetApplicationsAsync();
return true;
}
catch
{
return false;
}
}
/// <summary>
/// Tests connectivity to the Configuration Manager client (synchronous)
/// </summary>
/// <returns>True if the client is accessible</returns>
public bool TestConnection()
{
try
{
var apps = Applications.GetApplications();
return true;
}
catch
{
return false;
}
}
}
}