Full disclosure, I'm fairly new to PowerShell but a big fan. I'm trying to learn more and more so that I can leverage it for my organization.
I'm developing a script that logs into each controller and gathers information that I specify. It takes that informaiton and add/appends it to a file based on the controller name and date/time then attaches those files and sends an email.
The script works up until I check for the multistore license and start checking for different info. Any suggestions? Maybe I need to clean up my script, too. Any and all help would be appreciated.
I wen through your script, and i found that the credential parameter is missing for Connect-NaController, you will need to specify credentials as below, i have highlighted the text which needs to be appended in black.
Thank you for your help. I've fixed the credential portion (thanks for the catch) and I'm looking into hast tables.
I'm having trouble with lines 102 - 126 of my script. The variable is not populating with info and I'm having difficulty getting the 'if' portion of my script to check if a value is true, the continue to run the script.
#Check to see if the filer is licensed for multistore.
That did the trick! Thanks! One little character...
I originally used the second of your suggestions, if ($NFSiSCSIVerify.Licensed -eq $true ), but it still wouldn't work so I tried other things just to get some results. I appreciate your help and I'm still looking into hash tags.
I agree with Vinith in spirit in that it's better to export your data as objects, so that you can re-read them back into Powershell later and re-use them, but that might take quite a bit of rework on your part. This is how you would use this concept:
In our case, we have a script that does something very similar to what yours does. Once per day, it grabs the options and values off of all controllers using Get-NaOption. We then record that to a date stamped .xml file. We then read in the previous days' file values and compare the two. If there are differences, we get a report detailing what has changed. Another useful function is we can read in the .xml files and quickly re-apply the option values. Here is some example code:
I'd probably never do this exact exercise, but it illustrates what you can do with object-oriented output and input. XML works very nicely and the Export/Import-CliXML cmdlets make it very easy. In your case, you are exporting quite a bit of unlike data, so I'm not sure this is practical with your approach. I'd take a look and decide what works best for your application.
I see... My challenge becomes grabbing the file with the correct date and time... I could strip the time out of the file since I plan to run this only once a day. That would solve my filename problem. Thanks again!