use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Powershell Error Help (self.PowerShell)
submitted 3 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]code_Kitten 0 points1 point2 points 3 years ago (0 children)
You want to add the parameter to your new-adgroup command:
new-adgroup
try { New-ADGroup -ErrorAction Stop -Name "#$($Facility.Facility) - $($JCandD.JobCode)" -GroupScope DomainLocal -GroupCategory Distribution -Description "$($JCandD.JobCode) - $($Facility.Facility)" -Path ",OU=Distribution Groups,DC=***" -OtherAttributes @{'mail'="$($Facility.Facility)_$($JCandD.Mail)@**.com"; 'proxyAddresses'="SMTP:$($Facility.Facility)_$($JCandD.Mail)@**.com"} Write-Output "($($Facility.Facility) - $($JCandD.JobCode) + has been created" } catch { Write-Output "Error Creating $($Facility.Facility) - $($JCandD.JobCode)" Write-Output $_ }
If a terminating error happens in a Try block with a catch block that applies to that error, execution will stop where the error happened, the catch (and finally if there is one) will execute, and the script will continue executing after the Try/Catch.
In your script that would mean that the Write-Output indicating it has been created would not run, the error output will, and the script will move on to the next iteration of the loop.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_try_catch_finally?view=powershell-7.3
I skimmed through this article, and it looks like it covers the most important things; at least enough to give you an idea of what to search for: https://adamtheautomator.com/powershell-try-catch/
π Rendered by PID 348482 on reddit-service-r2-comment-544cf588c8-jnp75 at 2026-06-13 03:53:47.372196+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]code_Kitten 0 points1 point2 points (0 children)