Good afternoon everyone...
Let me start by stating that I am in no way a master of scripting. I do it only when I have a large project that requires one so please be kind.
My challenge at the moment is that I need to enumerate all shares on a number of machines. Preferably through an input file and output the results into a file on a local drive named $input.txt / $input being the computer name in this instance.
The problem that I have is that I cannot figure out how to pass the variable $input into the -FriendlyName value. If I can get that piece figured out, I'm ready to start rolling with the remainder of the script.
By the way - the value works fine when passed as a string rather than a variable but I do need to do this across several hundred PCs. I have tried with single and double quotes, tried brackets, parenthesis and all that fun stuff...
Any help would be very much appreciated!
SCRIPT IN ITS MOST BASIC FORM
$input= import-csv "c:\temp\scripts\shares\pcs.csv"
ForEach ($name in $input){
echo $input
Get-FileShare (Get-StorageFileServer -FriendlyName $input) >> c:\temp\scripts\shares\$input.txt
}