-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-RaaSInformation.psm1
100 lines (74 loc) · 3.15 KB
/
Get-RaaSInformation.psm1
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#REQUIRES -Version 4.0
<#
DISCLAIMER:
This Sample Code is provided for the purpose of illustration only and is not intended to be used in a production environment.
THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED AS IS
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
We grant You a nonexclusive, royalty-free right to use and modify the Sample Code and
to reproduce and distribute the object code form of the Sample Code,
provided that You agree:
(i) to not use Our name, logo, or trademarks to market Your software
product in which the Sample Code is embedded;
(ii) include a valid copyright notice on Your software product in which
the Sample Code is embedded; and
(iii) to indemnify, hold harmless, and defend Us and Our suppliers from and
against any claims or lawsuits, including attorneys' fees, that arise
or result from the use or distribution of the Sample Code.
Please note: None of the conditions outlined in the disclaimer above will supersede terms and conditions contained within the Premier Customer Services Description.
ALL CODE MUST BE TESTED BY ANY RECIPIENTS AND SHOULD NOT BE RUN IN A PRODUCTION ENVIRONMENT WITHOUT MODIFICATION BY THE RECIPIENT.
Author: Mark Warneke <mark.warneke@microsoft.com>
Created: <mm-dd-yyyy>
HELP
.SYNOPSIS
RaaS Client Setup
.DESCRIPTION
PowerShell script to gather information to make the RaaS Client start collecting
.PARAMETER
Computername
.EXAMPLE
Get-RaaSInfromation
C:\PS> Get-RaaSInformation
#>
<#
Brief descirption of the fuction.
#>
function Get-RaaSInformation {
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter()]
[string] $Computername
)
begin {
if(!$Computername) {
$Computername = "localhost"
}
$rObject = New-Object psobject -Property @{
ComputerName = $null
AOSInstanceFound = $false
AOSInstance = $null
}
}
process {
Write-Verbose("Obtaining Win32_ComputerSystem object for Computername")
$computer = Get-WmiObject Win32_ComputerSystem -ComputerName $Computername
$rObject.ComputerName = $computer.Name
Write-Verbose("Obtaining AOS Service Instances won't throw error due to wildecard search")
$aos = Get-Service | ? { $_.Status -eq "Running" -AND $_.DisplayName -match "Microsoft Dynamics AX Object" }
Write-Verbose("Could potentially find no AOS nothing")
try {
$rObject.AOSInstance = $aos[0].Name
$rObject.AOSInstanceFound = $true
}
catch {
Write-Error("AOS service instances not found")
$rObject.AOSInstance = "01"
}
Write-Verbose("Returning custom object")
$rObject
}
end {
}
}
export-modulemember -function Get-RaaSInformation