So, i needed to pull some information from the auditlog, so I wanted to put my powershell to work.. So, I queried something very simple... get-nasystemlog -auditlog -starttime 5/21/2012 | ? {$_.value -like "*resize*"} TimeStampDT Source Severity Keyword Target Value ----------- ------ -------- ------- ------ ----- 5/21/2012 8:09:10 AM filer debug IN rsh shell RSH INPUT COMMAND is priv set -q admin ; lun resize -f "/vol/vol1/qtlun/lun0" 500G ; result -l But to my surprise, it didn't return any username data. I had to query the audit log directly with powershell to gather what I was looking for.. I did something like gc auditlog | % { (if $_ -like "*resize*" -or $_ -like "*reservation*") Write-host $_ out-file -inputobject $_ -filepath c:\log.log -append } } I'm just curious why i can't pull the usernames from the audit log with native cmdlets...
... View more
Clinton... I'm all worked out.. I went with your approach. $filer = Connect-NaController <filer> -HTTPS -Credential <xxx> -Transient Invoke-NaSsh -Controller $filer -Command <command> I had it, but was totally blinded that I was connecting via rpc! Thx for clearing that up with me...
... View more
Yeah, i was under the assumption that it talks to the credentials cache after it was working.. It just didn't register in my brain fast enough! Yeah, I can totally add to the credentials cache. I have the logic in place to handle that as per system login/ID,... I'm gonna play around and let you know..
... View more
Clinton, I am connecting to the filer via rpc. But if i add the filers via add-nacredential -systemscope invoke-nassh works. I think that my concept is wrong. I am connecting to the controller as above but then invoking nassh. Thats i think whats throwing me off. essentially i dont need to connect to controller via connect-nacontroller before i launch the invoke ssh cmdlet.
... View more
Ok, I'm stumped ... Putting my script aside, i'm just doing basic work here and it's giving me fits.. Connect-nacontroller $filer I confirm connection $global:currentnacontroller for sanity check And then I am just typing a basic command... invoke-nassh -command "snmp init 0" And I'm getting thrown this error.. Invoke-NaSsh : Value cannot be null. Parameter name: Credentials not provided in cmdlet argument, specified controller, or credentials cache. At line:1 char:13 + invoke-nassh <<<< + CategoryInfo : InvalidArgument: (:) [Invoke-NaSsh], ArgumentNullException + FullyQualifiedErrorId : CredentialsNotSpecified,DataONTAP.PowerShell.SDK.Cmdlets.Toolkit.Ssh.InvokeNaSsh It's frustrating me to no end!!
... View more
So, we ran into an issue where we needed to start a bunch of snapvaults that for some reason or the other failed to start. (root cause to be determined) So I took this opportunity to test my netapp ps skills and for some reason i'm not liking what i'm seeing. I'm running a simple query get-nasnapvaultsecstatus | ? {$_.secondary -like "*servera*"} | Start-nasnapvaultsectransfer But i'm met with a big error: Start-NaSnapvaultSecTransfer : The qtree idle is not configured in snapvault. So, i said, that doesn't seem to be correct, so Then I did the following get-nasnapvaultsecstatus | ? {$_.secondary -like "*servera*"} | Select Destinationpath | out-file c:\log.log I figured I would hack my way through this and then did gc c:\temp\log.log | % { start-nasnapvaultsectransfer $_ } And i'm met with .. At line:1 char:61 + gc C:\log.log | % { start-nasnapvaultsectransfer <<<< $_ } + CategoryInfo : InvalidOperation: (filer:NaController) [Start-NaSnapvaultSecTransfer], ESNAPVAULTSETUP + FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.Snapvault.StartNaSnapvaultSecTransfer Start-NaSnapvaultSecTransfer : The qtree blah/blah is not configured in snapvault. But the qtree's are 100% configured... Ok, where' am I going wrong? thx josh
... View more
Eric, Thanks for the quick response.. I was "assuming" this would be a Boolean property under get-navol. I have updated my code and am testing it now.. $45day = Get-NaVol | where {$_.state -eq "online" -and $_.raidstatus -notmatch "read-only"}` | Get-NaSnapshot | where {((get-date)-$_.created).days -gt 46} Next I will be piping it to | remove-nasnapshot -confirm:$false
... View more
I figured this one would be fairly simple and I reviewed the help for both get-navol and get-navoloption but i'm not able to find exactly what I was looking for. I'm basically looping through our environment removing old snaps based on a criteria set but some filers have both source and snapmirrored (r/o) volumes. I was hoping there was an option in get-navol for read ony but i didn't see it anywhere Am I just overlooking this? Here's my basic code $45day = Get-NaVol | where {$_.state -eq "online" }` | Get-NaSnapshot | where {((get-date)-$_.created).days -gt 46}
... View more
I've adjusted the log file. I didn't quite like using sc $outfile to xls. added out-string -width 4096 | out-file $outfile. I had to use out-string b/c my volumes kept getting truncated b/c they were too long. I had to change the default behavior of the display window. Just make sure you adjust $ext to $ext = ".log"
... View more
OK, so here is the finished code. I wanted to be able to have one script and pass multiple arguments into it so we can schedule a task. To launch scheduled task "powershell.exe script.ps1 input1 input1 Or within powershell .\script.ps1 input1 input2 It's simple, but hopefully this will help someone else as well [Code] Param( $input1, $input2 ) ## Import DataonTap Import-Module Dataontap $hostfile = $input1 gc $hostfile | % { $C = Connect-NaController $_ # Set-NaOption replication.throttle.enable $input2 } [/code]
... View more
Clinton, I've been playing along with Add-nacredential. Seems pretty cool. Currently, the set of filers that i'm thinking about are not in the domain so that's why I am using -cred root. I assume if I add the credentials to each filer on the local cache I need to use -systemscope especially if I am going to schedule the job as Local system in task manager. The only bothering thing is that we need to update this when the root password changes.. Ugg.. Oh well, thx for the continued tips..
... View more
In our environment we sometimes get stale SME snapshots that start with {. So here is a little powershell script that will loop through all the filers and remove it. [Code] ### Mail "constants" $sendMailAs = "x" $recipients = "X" $subjectLine = "GUID LOG" $mailMessage = "GUID Report The Attached Snapshots have been removed from the filers." $smtpServer = "X" $priority = "high" ### File Constants $date = (get-date).toString('dd-MMM-yyyy_h-mm-ss') $ext = ".log" $outfile = "Exchange_GUID__" + $date + $ext $delim = "`t" Import-Module DataONTAP $hostfile = "exchange.txt" gc $hostFile |% { $nacontroller = Connect-NaController $_ Get-NaVol | Get-NaSnapshot -SnapName "{*" | select TargetName,Name,Created,Total,CumulativeTotal | ft @{Expression={$nacontroller};Label="Filer name";Width=20},@{Expression={$_.TargetName};Label="Volume";Width=40},@{Expression={$_.Name};Label="Name";Width=40},@{Expression={$_.Created.ToShortDateString()};Label="Created";Width=12},@{Expression={ConvertTo-FormattedNumber $_.Total DataSize "0.0"};Label="Total";Width=10},@{Expression={ConvertTo-FormattedNumber $_.CumulativeTotal DataSize "0.0"};Label="Cumulative";Width=10} | Out-File -filepath $outfile -append get-navol | get-nasnapshot -snapname "{*" | where-object {$_.busy -like "*false*"} | remove-nasnapshot -confirm:$false } ## Send Email Send-MailMessage -To $recipients -From $sendMailAs -Attachments $outfile -Subject $subjectLine -Body $mailMessage -Priority $priority -SmtpServer $smtpServer ##### [/code] Now, i'm not sure its the best way to do this, but it works. I wanted to ensure we weren't trying to delete busy snaps so I through in $_.busy -like "*false*". I tried -eq "false" but it wouldn't return anything which was confusing to me . Now remember i'm very new to powershell so any criticism is welcome. I didn't know a good way to log in one line and then delete in another so, I had to run the cmdlet again. Any suggestions for imporvement are welcome.
... View more
Thx guys. I ran show-nahelp and search on the cmdlets titles only for replication. I shoulda dug deeper for the options. I will play with the cmdlet tomorrow for sure. I plan on looping controllers through a scheduled task to turn it on and off. I will repost. Thx
... View more
I've been looking through the cmdlets for a global replication throttle option and i've come up empty. As we all know, there is no throttling schedule 'yet' on Ontap, so the idea I had was to just loop the controllers through a powershell script to turn replication on and off on a set schedule. I saw that you can do it per line with Invoke-NaSnapmirrorThrottle. That's not what we are looking for. Thanks
... View more
Eric, Thanks for the points, I will review the add-nacredential cmdlet. I still don't understand how that will work in an automated script job.. It can't prompt me for passwords. Will review this weekend. I will check out adjusting thta line to handle any Null values.. More to come next week.
... View more
I forgot to mention that i keep getting this trailing errror. I made sure the input file had no trailing spaces and I can't figure out where it's coming from.. a bit of annoying ERROR: ConvertTo-Csv : Cannot bind argument to parameter 'InputObject' because it is null. ERROR: At C:\temp\good\good\lagtime2.ps1:68 char:44 ERROR: + $dataToWrite = $snapMirrors | convertTo-Csv <<<< -delimiter $delim -noType ERROR: + CategoryInfo : InvalidData: (:) [ConvertTo-Csv], ParameterBindingValidationException ERROR: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToCsvCommand ERROR:
... View more
Clinton, Here's what I have so far.. There are a few flaws that I want to work on. I would rather not put the password stored in the script. I can compile it, but i was wondering if there is a better way to do this Also, i had to abandon the Format-table command b/c I couldn't figure out how to format-table and then dump to csv. Also, the way we are dumping to CSV is kind of lame. I would like to use native Excel API, but i know this is a lot more challenging and i'm not sure i'm ready for it. But basically this gets the job done for now. It's ugly but it works. Improvements, comments, suggestions are welcome and appreciated. ### Mail "constants" $sendMailAs = "xx" $recipients = "x $subjectLine = "Daily Exchange VSM LAG TIME" $mailMessage = "Daily Exchange VSM Lag time" $smtpServer = "x" $priority = "high" ### File Constants $date = (get-date).toString('dd-MMM-yyyy_h-mm-ss') $ext = ".xls" $outfile = "Exchange_VSM_Lag_" + $date + $ext $delim = "`t" ### Import Data OnTap Module # Check toolkit version try { if (-Not (Get-Module DataONTAP)) { Import-Module DataONTAP -EA 'STOP' -Verbose:$false } if ((Get-NaToolkitVersion).CompareTo([system.version]'1.7') -LT 0) { throw } } catch [Exception] { Write-Warning "This script requires Data ONTAP PowerShell Toolkit 1.7 or higher." return; } ### Define Lag time $lagtimeseconds = "86400" #24 hour lagtime ### Input File properties $hostfile = "hosts.txt" $accnt = "xx" $filerpassw = "xxx" $password = ConvertTo-SecureString $filerpassw -AsPlainText –Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $accnt,$password $snapMirrors = @() gc $hostfile | % { $C = Connect-NaController -credential $cred $_ $snapMirrors += Get-NaSnapmirror | where-object {$_.lagTime -gt $lagTimeSeconds} | Select SourceLocation,DestinationLocation,Status,State,LagtimeTS # | ft @{expression={$c};Label="Filer name";width=20},@{expression={$_.SourceLocation};Label="Source";Width=40},@{Expression={$_.DestinationLocation};Label="Destination";Width=40},@{expression={$_.status};Label="status";width=20},@{Expression={$_.state};Label="state";width=20},@{Expression={$_.lagtimets};label="lag time";width=20} } $dataToWrite = $snapMirrors | convertTo-Csv -delimiter $delim -noType $dataToWrite | sc $outfile ## Send Email Send-MailMessage -To $recipients -From $sendMailAs -Attachments $outfile -Subject $subjectLine -Body $mailMessage -Priority $priority -SmtpServer $smtpServer #####
... View more
Clinton, Got my heads back with the following code.. I took your advince from the previous thread.. Still needs work but it's a start $lagtimeseconds = "86400" gc $hostfile | % { $c = Connect-NaController $_ -credential $cred Get-NaSnapmirror | where-object {$_.LagTime -gt $LagTimeSeconds} | Select SourceLocation,DestinationLocation,Status,State,LagtimeTS | ft @{expression={$c};Label="Filer name";width=20},@{expression={$_.SourceLocation};Label="Source";Width=40},@{Expression={$_.DestinationLocation};Label="Destination";Width=40},@{expression={$_.status};Label="status";width=20},@{Expression={$_.state};Label="state";width=20},@{Expression={$_.lagtimets};label="lag time";width=20} } I had to increase the widths b/c our volume are quite long. I'm not a true fan of how i did filer name, but it's a start. I would more like *** Filer Name **** blah blah That's for tomorrow.. And then i will do the same for snapvault status.. This will really helps us out. I knew you converted lagtimTS into days and hours. I'm thinking how I would do this in VB. I would create a function that does that that I can whip a variable through to convert. is it something similiar?
... View more
Clinton, Now i'm sort of getting somewhere I took your advice from the other thread and have come up with this " gc $hostfile | % { $c = Connect-NaController -credential $cred $_; Write-Host "`nController: $c`n"; Get-NaSnapmirror | where-object {$_.LagTime -gt $LagTimeSeconds} } " A few things i'm noticing. As the script loops through it strips out the headers on each loop. so for the first example it only lists Controller: filera Source Destination Status State LagTimeTS ------ ----------- ------ ----- --------- Also, what is the best way to write the host name like we are and then if it doesn't meet the criteria to write "no snapmirror lag issue" I was thinking along the lines of $lag = Get-NaSnapmirror | where-object {$_.LagTime -gt $LagTimeSeconds Am i totally off base? I'm also noticing the built in formatting is not big enough for some of our volume names. I am going to work on that with the expression statements like you did in the other post. I will re-post when im done.
... View more
It would be cool if i knew a way to convert 3.05:14:59 to days, hours, minutes, seconds. So, like 3days,5hours,15minutes,59seconds Is that a powershell expression that needs to happen?
... View more
Clinton, Ok, i like the output and what you did for the built in formatters. I had to adjust column width based on lenght of name of vol and snap. [Quote} gc $hostFile |% { $nacontroller = Connect-NaController $_ -Credential $cred -Transient:$true Get-NaVol | Get-NaSnapshot -SnapName "{*" | select TargetName,Name,Created,Total,CumulativeTotal | ft @{Expression={$_.TargetName};Label="Volume";Width=40},@{Expression={$_.Name};Label="Name";Width=40},@{Expression={$_.Created.ToShortDateString()};Label="Created";Width=12},@{Expression={ConvertTo-FormattedNumber $_.Total DataSize "0.0"};Label="Total";Width=10},@{Expression={ConvertTo-FormattedNumber $_.CumulativeTotal DataSize "0.0"};Label="Cumulative";Width=10} } [/quote] So I have some questions. Why on earth is the loop not going through the file. It keeps hitting the first controller in the file. Its driving me nuts.. Also, based on your expression statement, when you are adjusting the size you use DateSize "0.0". What is that actually doing behind the scenes? Im curious? Thanks
... View more