jeudi 7 avril 2016

Searching through specific network shares using User Input data

I am writing a script that will prompt for a first and last name. After this information is submitted it will search two shares for anything matching the data input. If something is found, a message will display "Item found". If not, message will display saying "Item not found". This is what I have so far:

$FirstName = Read-host "Enter First Name"
$LastName = Read-host "Enter Last Name"

$Var1 = "\\ServerA\Folder1\Folder2\Folder3\FolderA"
$Var2 = "\\ServerA\Folder1\Folder2\Folder3\FolderB"
$Var3 = Get-childitem -path $Var1 -recurse -name *.gho
$Var4 = Get-ChildItem -path $Var2 -recurse -name *.gho

If
($FirstName + $LastName -eq $Var3,$Var4){Write-host "Item Found"}
Else
{Write-host "Item not found"}

I am not sure if I need to use an If/Else statement or try/catch with this. I know it's a syntax error but I don't know what it is.

Thank You!

Aucun commentaire:

Enregistrer un commentaire