4sysops - The online community for SysAdmins and DevOps
thedavecarroll commented on Set up a Hyper-V home lab with the AutomatedLab PowerShell module 3 years, 6 months ago
I just ran the following:
New-LabSourcesFolder -DriveLetter D
You can always use the Get-Help cmdlet to see what parameters are available to commands.
New-LabSourcesFolder [[-DriveLetter] <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Hope that helps.
Luc Fullenwarth commented on Auto-archive attachments from an Exchange mailbox with PowerShell 3 years, 7 months ago
Are you sure the mailbox name in line 2 of the script is correct?
Also did you update the Exchange version of line 12?
Luc Fullenwarth commented on Stop or exit a PowerShell script when it errors 3 years, 7 months ago
The Try/Catch statement is working like this:
Let’s TRY something, and if it’s throwing an error, let’s CATCH the error to see how we will handle it.
But your third example shows that you already understood this principle.
Just an additional information:
Don’t assume that there is only one possible error. There are many ways something can go wrong. Usually, I catch known errors and return the original exception when unknown errors are raised.
In your example this would give something like:
$users = Get-ADUser -Filter * -Properties proxyAddresses -ErrorAction Stop
write-host 'This script requires AD module be loaded, try again after it is.'
You can achieve that with the try/catch statements. The try statement suppresses all output. Then inside the catch statement, you can choose which part of the error you want to display.
throw 'My Custom Error Message'
$error is an array with all former exceptions. $Error is the latest one. Each error has several properties.
$error|Get-Member -MemberType Properties
I choose in my example to display the Exception property because this is probably what you want, but you can display any of them.
Luc Fullenwarth commented on Arrays in PowerShell – Create, change, read, sort, delete 3 years, 10 months ago
There are many ways to manipulate arrays. Wolfgang’s post is very good to help beginners to understand the basic concepts.
Seems like you improved you skills in this domain with Array classes… 😉
However, for information and according to Microsoft (directly in the link you provided).
Please ask IT administration questions in the forums. Any other messages are welcome.
or Create an account
Receive news updates via email from this site