0

I am exporting drive name movies in text file.

Get-WmiObject win32_logicaldisk| foreach-object {$volumename -Match "movies" } | select movies > c:\nn.txt

And later comparing it but not successful always getting false result can anyone help?

$test=Get-WmiObject win32_logicaldisk| foreach-object {$volumename -Match "movies" } | select movies > c:\nn.txt
    $array =get-content c:\nn.txt
    $real= Get-WmiObject win32_logicaldisk| foreach-object {$volumename -Match "movies"} | select movies
    If ($array -eq $real)

    {write-host "it was success" -foregroundcolor blue}
    Else {write-host "it was fail" -foregroundcolor green}

1 Answer 1

0
get-wmiobject win32_logicaldisk | ? Volumename -eq "movies" | select -ExpandProperty Volumename | out-file "c:\nn.txt"
$array =get-content  "c:\nn.txt"
$real =  get-wmiobject win32_logicaldisk | ? Volumename -eq "movies" | select -ExpandProperty Volumename
If ($array -eq $real)

{write-host "it was success" -foregroundcolor blue}
Else {write-host "it was fail" -foregroundcolor green}
2
  • This command get-wmiobject win32_logicaldisk | ? Volumename -eq "movies" | select -ExpandProperty Volumename not suppoted in powershell 2.0 Jul 1, 2016 at 20:58
  • use get-wmiobject win32_logicaldisk | ? {$_.Volumename -eq "movies"} | select -ExpandProperty Volumename
    – Sergei
    Jul 2, 2016 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .