iVenture_Solutions
asked on
FSRM Script Using Get-Content to Read Blocked and Allowed files from Text Documents
Hello. We have recently been rolling out File Server Resource Manager and using it to alert us of file names containing the word "*decrypt*". Our script reads the files to screen from a file called screen.txt. The excluded files in this File Group are read from WList.txt.
At this point we have multiple files to exclude in this file group, but when the script gets the content from the file, the file names (all separate lines in the text file) are all entered together on the same line, so instead of excluding:
File1
File2
File3
it excludes File1File1File3.
Here is my code.
Can anyone help me place this in a proper array?
Thanks for your time.
At this point we have multiple files to exclude in this file group, but when the script gets the content from the file, the file names (all separate lines in the text file) are all entered together on the same line, so instead of excluding:
File1
File2
File3
it excludes File1File1File3.
Here is my code.
$FGroup = Get-Content C:\windows\ltsvc\scripts\Screen.txt
$WList = Get-Content C:\windows\ltsvc\scripts\wList.txt
New-FsrmFileGroup -name "CryptoFileScreen" -includepattern "$FGroup" -ExcludePattern "$WList"
Can anyone help me place this in a proper array?
Thanks for your time.
ASKER
Hi oBdA,
I have tried that previously. Taking your advice, I removed the quotes, but I am still ending up with the File Screens' excluded patterns being entered as one single file name.
I have tried that previously. Taking your advice, I removed the quotes, but I am still ending up with the File Screens' excluded patterns being entered as one single file name.
New-FsrmFileGroup -name "CryptoFileScreen" -includepattern $FGroup -ExcludePattern $WList
Can't reproduce this.
Does it only happen for the exclude file or for the include file as well?
How are you creating the text file?
Did you remove the old "CryptoFileScreen" file group before retrying the script?
What is the output of
Does it only happen for the exclude file or for the include file as well?
How are you creating the text file?
Did you remove the old "CryptoFileScreen" file group before retrying the script?
What is the output of
(Get-Content C:\windows\ltsvc\scripts\wList.txt).Count
Does this work:New-FsrmFileGroup -Name "Dummy" -IncludePattern @(".foo", ".bar") -ExcludePattern @("acme", "contoso")
ASKER
oBdA, I haven't had a chance to try modifying this script, but I will let you know if this works for me. I can tell you that adding files in the script directly does work when I add multiple files.
Using Get-Content to read from the text files, I am having the same issue with both the pattern I want to include as well as the patterns I want to exclude.
Using Get-Content to read from the text files, I am having the same issue with both the pattern I want to include as well as the patterns I want to exclude.
ASKER
Hello.
I was able to get this working properly for 2012 R2. I am not using quotes around the variable names.
In 2008 R2, I am still having the same issue. The line in the script for 2008 R2 is:
I have tried this with and without the quotes around the variable name. The files in the text document are still showing up as one file name for 2008 R2.
I was able to get this working properly for 2012 R2. I am not using quotes around the variable names.
In 2008 R2, I am still having the same issue. The line in the script for 2008 R2 is:
filescrn Filegroup Add /Filegroup:"CryptoFileScreen" /Members:$FGroup /nonmembers:$WList
I have tried this with and without the quotes around the variable name. The files in the text document are still showing up as one file name for 2008 R2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect. That is exactly what I needed. Thank you so much for the help.
Open in new window