Attempting to create a script that prompts for a specified AD group name to verify if user accounts are disabled and create an output file with the output displayed from PowerShell.  So far this is what I have but I am receiving an blank output.


$group = [Microsoft.VisualBasic.Interaction]::InputBox("Please enter group name", "Group", "$env:username")

Get-ADGroupMember -identity "$group" | get-aduser | Where {$_.Enabled -eq $false} | format-table name -autosize

Out-File -Force "C:\AD_output.txt"
U.S.Infrastructure Engineer Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Because you're writing nothing to the file (and the LoadWithPartialName is deprecated - use Add-Type instead).
Try it like that, for example:
Add-Type -AssemblyName Microsoft.VisualBasic
$groupName = [Microsoft.VisualBasic.Interaction]::InputBox("Please enter group name", "Group", "$env:username")
$groupMembers = Get-ADGroupMember -Identity $groupName | Get-ADUser -Property DisplayName | Where-Object {-not $_.Enabled}
$groupMembers | Format-Table -Property Name -AutoSize
$groupMembers | Select-Object -Property SamAccountName, Name, DisplayName | Export-Csv -NoTypeInformation -Path "C:\AD_output.csv"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
U.S.Infrastructure Engineer Author Commented:
Awesome this works beautifully! Thanks for helping out a newbie to PS.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.