hello everyone, I am having a little bit of a issue trying to get the out-file command to print to a text file on $dis = "2". it still prints to the screen. any help is welcomed thank all
functionSkyzone1{
""
write-host"Script will retrieve the User system by whats in the description field in AD"-foregroundcolor"red"
""
$dis=Read-host'would you like to 1. display on screen 2. Write to cvs'
cls
if ($dis="1"){
$d=Read-Host"Enter User name"
""
$d= "*$d*"
Get-ADComputer-Filter {Description-Like$d} -SearchBase$skyzone-PropertiesDescription,name,LastLogonDate|select-objectName,Description,LastLogonDate
Pause
}
elseif($dis="2") {
$dp=Read-Host"Enter User name"
""
$dp= "*$dp*"
Get-ADComputer-Filter {Description-Like$dp} -SearchBase$skyzone-PropertiesDescription,name,LastLogonDate|Out-File-FilePathC:\Temp\results2.txt
}
Else{
write-host"Not a vaild option"
}
}