Skip to content

Commit f062875

Browse files
authored
Update script to check for APM class before trying to set the class in the RunAs Profile 📽️
1 parent c679e9d commit f062875

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Powershell/Quick Fixes/Resolve-DWRunAsProfileAssociation.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Original Blog Post: https://udishtech.com/associate-scom-data-warehouse-profile-using-powershell/
33
# =========================================================================================================================
44
# Modified by: Blake Drumm (blakedrumm@microsoft.com)
5-
# Last Modified: September 28th, 2022
5+
# Last Modified: March 8th, 2024
66
# Blog Post: https://blakedrumm.com/blog/data-reader-account-provided-is-not-same-as-that-in-the-management-group/
77

88
function Invoke-TimeStamp
@@ -35,7 +35,14 @@ Write-Output "$(Invoke-TimeStamp)Setting the Run As Account Association for Data
3535
$error.Clear()
3636
try
3737
{
38-
Set-SCOMRunAsProfile -ErrorAction Stop -Action "Add" -Profile $DWActionAccountProfile -Account $DWActionAccount -Class $CollectionServerClass, $DataSetClass, $APMClass, $DWSyncClass
38+
if ($APMClass)
39+
{
40+
Set-SCOMRunAsProfile -ErrorAction Stop -Action "Add" -Profile $DWActionAccountProfile -Account $DWActionAccount -Class $CollectionServerClass, $DataSetClass, $APMClass, $DWSyncClass
41+
}
42+
else
43+
{
44+
Set-SCOMRunAsProfile -ErrorAction Stop -Action "Add" -Profile $DWActionAccountProfile -Account $DWActionAccount -Class $CollectionServerClass, $DataSetClass, $DWSyncClass
45+
}
3946
Write-Output "$(Invoke-TimeStamp)Completed Successfully!"
4047
}
4148
catch

0 commit comments

Comments
 (0)