/ Published in: Windows PowerShell
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
param([switch]$y) $fulldir="blank" $uselast = "n" $check="n" $result = " " $root=Q: $a=0 $b=-1 if(Test-Path H:\fileinfo.ps1_lastuseddir){ $uselast = Read-Host "Would you like to use your last search values?(y/n)" } if($uselast = "n"){ $hold = Read-Host "Live or Test?" if($hold = "Live"){ $root = "R:" }elseif($hold = "live"){ $root = "R:" }elseif($hold = "Test"){ $root = "Q:" }elseif($hold = "test"){ $root = "Q:" }else{ "Unable to process input, defaulting to test" $root = "Q:\" } $search_ident = Read-Host "What is the clinic name?" if($fulldir = "blank"){ [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse $count = $search.count while($b -lt $count){ $b++ $result = ($search[$b]).fullname if($result -ne $Null){ $check = Read-Host "Is $result correct?(y/n)" } if ($check -eq "y"){ "35 $check" $fulldir = $result } } $b=-1 if($fulldir = "blank"){ $search_ident = ($search_ident) -replace “ â€, â€_“ [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse $count = $search.count while($b -lt $count){ $b++ $result = ($search[$b]).fullname if($result -ne $Null){ $check = Read-Host "Is $result correct?(y/n)" } if ($check -eq "y"){ "Debug:45" $check $fulldir = $result } } $b=-1 if($fulldir = "blank"){ $search_ident = ($search_ident) -replace “_â€, â€â€œ [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse $count = $search.count while($b -lt $count){ $b++ $result = ($search[$b]).fullname if($result -ne $Null){ $check = Read-Host "Is $result correct?(y/n)" } if ($check -eq "y"){ $check "Debug:60" $fulldir = $result } } } } if($fulldir = "blank"){ "Client not found, restarting application." H:\FileInfo.ps1 } } $dira=Read-Host "Results or Orders?" $dirb=Read-Host "In, Out, or Arc?" $fulldir=$fulldir+"\"+$dira+"\"+$dirb Set-ItemProperty -Path H:\fileinfo.ps1_lastuseddir -Name Attributes -Value ([System.IO.FileAttributes]::Normal) -Force | out-null Remove-Item H:\fileinfo.ps1_lastuseddir -force | out-null New-Item H:\fileinfo.ps1_lastuseddir -type file -force | out-null "$fulldir" > H:\fileinfo.ps1_lastuseddir Set-ItemProperty -Path H:\fileinfo.ps1_lastuseddir -Name Attributes -Value ([System.IO.FileAttributes]::Hidden) | out-null }elseif($uselast = "y"){ $fulldir = (Get-Content H:\fileinfo.ps1_lastuseddir) } $filecount = (Get-ChildItem $fulldir).Count if($filecount = "0"){$filecount = "zero"} "The full path is $fulldir" "There are currently "+"$filecount"+" files in the folder." $a=0 $b=0 if ($a=0){ } CD H: