You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: intune/configmgr/develop/core/understand/calling-code-snippets.md
+98-11Lines changed: 98 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,97 @@ ms.subservice: sdk
6
6
ms.topic: article
7
7
ms.collection: tier3
8
8
---
9
+
9
10
# Calling Configuration Manager Code Snippets
11
+
10
12
The following code samples show how to set up the calling code for the code examples that are used throughout the Configuration Manager Software Development Kit (SDK).
11
13
12
-
Replace the SNIPPETMETHOD snippet with the snippet that you want to run. In most cases you will need to make changes, such as adding parameters, to make the code work.
14
+
Replace the SNIPPETMETHOD snippet with the snippet that you want to run. In most cases you will need to make changes, such as adding parameters, to make the code work.
15
+
16
+
For more information about remote Windows Management Instrumentation (WMI) connections, see [Connecting to WMI on a Remote Computer](/windows/win32/wmisdk/connecting-to-wmi-on-a-remote-computer.md).
17
+
18
+
## Examples
19
+
20
+
```powershell
21
+
# Prompt for computer name
22
+
$computer = Read-Host "Computer you want to connect to (Enter . for local)"
23
+
24
+
# Determine whether to prompt for credentials
25
+
if ($computer -eq ".") {
26
+
$credential = $null
27
+
}
28
+
else {
29
+
$credential = Get-Credential -Message "Enter credentials for $computer"
if ($Credential) { $siteParams.Credential = $Credential }
13
78
14
-
For more information about remote Windows Management Instrumentation (WMI) connections, see [Connecting to WMI on a Remote Computer](/windows/win32/wmisdk/connecting-to-wmi-on-a-remote-computer).
> The assemblies are in the \<Program Files>\Microsoft Endpoint Manager\AdminConsole\bin folder.
320
+
> The assemblies are in the \<Program Files>\Microsoft Endpoint Manager\AdminConsole\bin folder.
236
321
237
322
## Runtime Requirements
238
-
For more information, see [Configuration Manager Server Runtime Requirements](../../../develop/core/reqs/server-runtime-requirements.md).
323
+
324
+
For more information, see [Configuration Manager Server Runtime Requirements](../../../develop/core/reqs/server-runtime-requirements.md).
239
325
240
326
## Robust Programming
241
-
The Configuration Manager exceptions that can be raised are [SmsConnectionException](/previous-versions/system-center/developer/cc147431(v=msdn.10)) and [SmsQueryException](/previous-versions/system-center/developer/cc147436(v=msdn.10)). These can be caught together with [SmsException](/previous-versions/system-center/developer/cc147433(v=msdn.10)).
327
+
328
+
The Configuration Manager exceptions that can be raised are [SmsConnectionException](/previous-versions/system-center/developer/cc147431(v=msdn.10)) and [SmsQueryException](/previous-versions/system-center/developer/cc147436(v=msdn.10)). These can be caught together with [SmsException](/previous-versions/system-center/developer/cc147433(v=msdn.10)).
0 commit comments