I am trying to compare files between two different folders and then if there are differences I would like to output it to a txt file. Right now I can show the differences but I am unable to write the results in the txt file.
Here is what I have so far:
foreach($file in dir)
{
$fileName =...
That did the trick!
The only thing that I changed was commenting out the first foreach ($folder in get-childitem) because it made an endless loop. So I removed that and it worked great.
Thank You for all of your hard work!!!
There is a name property and there is a script method.
As far as I know they are all objects.
Not that I am an expert by any means but what I have so far will create a single text file with a static name. Inside the file it has the script of all of the stored procedures in the directory. So...
You are exactly right up to the point about naming the files. I want to name each file with the name of the stored procedure that it is scripting out.
So if there are 10 procs in the dir then there will be 10 txt files each with the name of the proc that is in the directory.
Does that make...
I'm still a newbie here. When you say preceding loop and you talking about putting it inside the {} directly following the $_.script() and would I still have to pipe it to the out-file?
Is this what you mean:
foreach ($Name in Dir) { gci | % {$_.script() | out-file "c:\$Name.txt"}
?
Thanks!
When I write that it gives me an error mentioning:
+ for each ($name in dir){gci | % {$_.script()} | out-file <<<< "c:\$name.txt"}
Out-File : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
I have no idea where to go from there?
In powershell through sqlServer:\sql\servername\default\databases\databasename\storedprocedures> I am able to create a text or .sql file with all of the stored procs in the directory into one text file. I am wondering how I can script each stored proc into it's own .sql or txt file.
Here is...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.