Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requires .NET 2.0 to run.
So before I go on I would like to ask for help here, if my idea would even work and if I'm on the correct path. Maybe there is a easier solution or it will not ven work, maybe i need parameters ( i dont think so) or specify the output of the script (i dont know how).
I read the manual (Use case: Create a SAM template that uses the Windows PowerShell Monitor to detect possible dictionary attacks (solarwinds.com)), but it forks and forks until I really had no idea anymore.I guess there are examples of powershell monitors and I'm for sure not the only one who wants to get activation/license information from their servers, so I would be grateful if someone can put me in the right direction.
The next /much more complex) script (with several parameters as a result) would gather information about open Windows Updates. The script is already done, but since it also uses WIM/RPC i can't use it and must utilize Orion for it.
My advice, don't use powershell to find differences in files. As someone else noted, fc works, and works a little better than compare-object, and even better is downloading and using real tools like the unix emulator that Mikeage mentioned.
compare-object is designed to determine if 2 objects are member-wise identical. if the objects are collections then they are treated as SETS (see help compare-object), i.e. UNORDERED collections without duplicates. 2 sets are equal if they have the same member items irrespective of order or duplications. This severely limits its usefulness for comparing text files for differences. Firstly, the default behaviour collects the differences until the entire object (file = array of strings) has been checked thus losing the information regarding the position of the differences and obscuring which differences are paired (and there is no concept of line number for a SET of strings). Using -synchwindow 0 will cause the differences to be emitted as they occur but stops it from trying to re-synchronise so if one file has an extra line then subsequent line comparisons can fail even though the files are otherwise identical (until there is a compensatory extra line in the other file thereby realigning the matching lines). However, powershell is extremely versatile and a useful file compare can be done by utilising this functionality, albeit at the cost of substantial complexity and with some restrictions upon the content of the files. If you need to compare text files with long (> 127 character) lines and where the lines mostly match 1:1 (some changes in lines between files but no duplications within a file such as a text listing of database records having a key field) then by adding information to each line indicating in which file it is, its position within that file and then ignoring the added information during comparison (but including it in the output) you can get a *nix diff like output as follows (alias abbreviations used):
As others have noted, if you were expecting a unix-y diff output, using the powershell diff alias would let you down hard. For one thing, you have to hold it's hand in actually reading files (with gc / get-content). For another, the difference indicator is on the right, far from the content -- it's a readability nightmare.
The -force argument is required because Powershell is quite precious about this particular inbuilt alias. If anyone is interested, having GnuWin32 installed, I also include the following in my powershell profile: