I
I
Ivan Zhukov2015-04-10 09:14:37
PowerShell
Ivan Zhukov, 2015-04-10 09:14:37

How to write a profile availability check for multiple AD users?

Wrote a small check for the existence of a profile on the server. But it only works for one account. The truth is written clumsily, but still.

$ListProfileForRemove = (Get-ADUser –Identity i.zhukov | foreach { $_.SamAccountName}).ToString()
foreach ($ListUsersForRemove in $ListProfileForRemove)
{
    $testPathGrapes = Test-Path "\\grapes\c$\Users\$ListProfileForRemove"
        If ($testPathGrapes -eq $True) {
        Write-Host "На сервере GRAPES доступны файлы профиля"
        }
        Else {
        Write-Host "На сервера GRAPES файлы профиля не доступны"
        }
}

How to write an illogical check for multiple user accounts given in a variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pukhov, 2015-04-10
@Neuroware

By what criteria should these "few" be formed? Random?
In fact, the list is formed in these commands Get-ADUser –Identity i.zhukov
instead of them, for example, Get-AdUser -Filter 'name -Like "Test *"
will select all users starting with Test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question