From cf16558acc9c603a238065593509a7a55dab7b23 Mon Sep 17 00:00:00 2001 From: Oscar Pocock Date: Fri, 20 Jan 2023 16:33:26 +0000 Subject: [PATCH] Added error if resource can't be found for GetInfoFromUniqueId.ps1 --- GetInfoFromUniqueId.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GetInfoFromUniqueId.ps1 b/GetInfoFromUniqueId.ps1 index 454dc62..35d74b2 100644 --- a/GetInfoFromUniqueId.ps1 +++ b/GetInfoFromUniqueId.ps1 @@ -43,10 +43,7 @@ else { } foreach($object in $returnedObjects.Policies) { - if ($objectFound -eq $true) { - break - } - elseif ("$target" -eq "$($object.PolicyId)") { + if ("$target" -eq "$($object.PolicyId)") { if ($name -eq $true) { Write-Output "$($object.PolicyName)" } @@ -58,4 +55,7 @@ foreach($object in $returnedObjects.Policies) { } return } -} \ No newline at end of file +} + +Write-Output "Unique ID '$target' not found" +exit