Glenn, you can correct me if i'm wrong, but i believe he has to iterate through the objects with a for loop so for example foreach ($route in $routelist) { write-host "destination:" $route.destination } If you want it as a variable, you need to set it like $var = $route.destination and then if you want to do an if statement it would be if ($var -eq "default") { "put code here" } Hope I didn't confuse you
... View more
Unless I'm misunderstanding.. I agree with Beam. There is no audit log on the vfiler. All logs reside on the controller's /etc$ directory The get-nasystemlog will query the logs in the etc$ on the filer themself.
... View more
First, I want to thank Glenn Sizemore for his kick ass approach of scripting and mirroring the Igroups..(See other thread) Here's the completed script to mirror igroups, initiators and LUN Mappings..- For the purpose of testing I threw an If statement in there to grab just one igroup. You can remove the if statement if you want all igroups.. $sourcecontroller = Connect-NaController filera $dstcontroller = Connect-NaController filerb # Get Lun Info on Source Controller $igroups = Get-NaIgroup -Controller $sourcecontroller $LunInfo = Get-NaLun -Terse -Controller $sourcecontroller | where-object {$_.path -notlike "*sv*"} | Get-NaLunMap -Controller $sourcecontroller | Group-Object Name ## Loop through existing $igroup info foreach ($Igroup in $igroups) { if ($Igroup.name -eq "igroupname") { #Write-out command for testing igroup creation" Write-Host "`nCreating Igroup:" $Igroup.name "On controller" $dstcontroller Write-Host "--------------------------------------------------------" New-NaIgroup -Name $Igroup.Name -Type $Igroup.type -protocol $Igroup.protocol -controller $dstcontroller -confirm:$false ## Adding initators to Igroup Write-Host "`nAdding Initators: " $Initiators " to Igroup" $Igroup.name $Initiators = $iGroup.Initiators | Select-Object -ExpandProperty 'InitiatorName' $Initiators | Add-NaIgroupInitiator -igroup $igroup.name -Controller $dstcontroller -confirm:$false Write-Host "`n" ### Add Lun Mappings for Igroup Write-Host "`nAdding Lun Mappings for: " $Igroup.name foreach ($lun in ($LunInfo| where {$_.Name -eq $igroup.Name} | select -ExpandProperty Group)) { Write-Host "`t`t`tLUN:" $lun.lunID ":" $lun.path Add-NaLunMap -Path $lun.path -InitiatorGroup $Igroup.name -ID $lun.lunid -Controller $dstcontroller -verbose } } }
... View more
Glenn - Excuse my oversight.. I See that you have piped in $initiators Once I adjusted this line - $Initiators | Add-NaIgroupInitiator -igroup $igroup.name -Controller $dstcontroller -confirm:$false it's working like a charm.. I did man on it and saw that it accepts pipeline input. So, what's the technical reason why my code will fail? Is it because it's an array and the cmdlet doesn't know how to interpret it? Just curious...
... View more
Ah.. Ok, i'm getting a frustrated as i've looked at your examples, but i'm unable to replicate the initiators... Here is the code extracted and modified a little. $sourcecontroller = Connect-NaController source $dstcontroller = Connect-NaController destination $igroups = Get-NaIgroup -Controller $sourcecontroller ## Loop through existing $igroup info foreach ($Igroup in $igroups) { if ($Igroup.name -eq "testigroup") { #WRite-out command for testing igroup creation" Write-Host "`nCreating Igroup:" $Igroup.name "On controller" $dstcontroller Write-Host "--------------------------------------------------------" New-NaIgroup -Name $Igroup.Name -Type $Igroup.type -protocol $Igroup.protocol -controller $dstcontroller -confirm:$false ## write-out command for testing adding initiators" $Initiators = $iGroup.Initiators | Select-Object -ExpandProperty 'InitiatorName' Add-naigroupinitiator -igroup $igroup.name -initiator $Initiators -Controller $dstcontroller -confirm:$false -whatif Write-Host "`n" } } That will create an igroup without issue but the Add-naigroupinitiator spits up errors at me. Add-NaIgroupInitiator : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Initiator'. Specified method is not supported. At C:\Powershell\sg colo\igroupcreationAnode.ps1:32 char:55 + Add-naigroupinitiator -igroup $igroup.name -initiator <<<< $Initiators -Controller $dstcontroller -confirm:$false -whatif + CategoryInfo : InvalidArgument: (:) [Add-NaIgroupInitiator], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,DataONTAP.PowerShell.SDK.Cmdlets.Igroup.AddNaIgroupInitiator now if i manually just enter one initiator it works.. but it doesn't handle the mutliple initators well. Also in your code example, I'm not seeing where you add any initiators Your posted code has this. # Add any missing initiators from the source $Initiators = $I.Initiators | Select-Object -ExpandProperty 'InitiatorName' $IGroup.Initiators | Where-Object { $Initiators -notContains $_.InitiatorName } | Add-NaIgroupInitiator -Igroup $I.InitiatorGroupName ` -Controller $DestinationController Did I miss something? Can add-nainitiator not handle multiple initiators. like add-naigroupinitiator -igroup testigroup -initiator 50:01:43:80:05:67:55:4e,50:01:43:80:05:67:5b:0c -Controller dstcontroller what gives here?
... View more
Glenn and team: So i'm just playing out with the output a little before the next step, but I have a ? foreach ($lun in ($LunInfo| where {$_.Name -eq $igroup.Name} | select -ExpandProperty Group)) { Write-Host "`t`t`tLUN:" $lun.lunID ":" $lun.path } I was looking at $luninfo, and i'm not quite sure how you got $lun.lunid and $lun.path.. And the reason I ask is b/c I tried do something like if ($lun.lunid -ne $null) { Write-Host "`t`t`tLUN:" $lun.lunID ":" $lun.path } else {write-host "No active mappings"} But my results were not what I thought they would be.. all thoughts are well appreciated. thx
... View more
Glenn - Yuu absolutely rock right now.!! I loved your note on replicating igroups to another filer b/c that is essentially what I want to do... I had thoughts of doing it your way but I figured i would be safe and dump to a file and then run another script.. From a reporting standpoint your script kicks butt!.. But if I'm going to replicate everything to another filer, igroups, lunID's, mapping etc, I'm going to need to put it in a little different format.. Where was I going wrong with my original script? A few ?'s for you. I see you ran -Group Name for this line - $LunInfo = Get-NaLun -Terse | where-object {$_.path -notlike "*sv*"} | Get-NaLunMap | Group-Object Name I'm just curious as to why you did grouping by name? is that so it truncates the initiators? Also, when you use select-object, I understand expandproperty - but -join does what? Also, i'm not quite sure what you're doing with this - Write-Host ("`t`t`t {0:0} {1}" -f $lun.lunid, $lun.path) what's {0:0} {1} and -f I did a man on write-host but it didn't lead me to it.. Also, since you are the expert, and I need to replicate this entire configuration, I was going to try to dump it to a file and then read through the file to build the scripts I need for our DR filer. Is that totally off base? Thanks in advance..
... View more
Yeah.. i went through that as well.. Your code still prodocues my same problem Name LunID Initiators ---- ----- ---------- igroupname 11 {50:01:43:80:05:67:55:4e, 50:01:43:80:05:67:5b:0c, 50:01:43:80:05:67:5a:e4, 50:01:43:80:05:67:55:54...} The reason I need to do all this is b/c i need to setup an exact same filer with igroups and lun mappings for DR.. it's a long story.. but i thought i was on easy streat until i noticed the initiators truncated I'm taking the output of these commands and i'm parsing through the output to do eventually create a command new-naigroup -name $name -protocol $protocl -type $type I can pretty much get to dthat, it's all the rest of the automation that's coming along.
... View more
Hmm.. Ok, I have a fundamental bug in the script which I just caught.. If you have more than 4 initiators in the output gets cut off.. So then i tried to change the following line # $igroup = Get-NaIgroup to $igroup = get-naigroup | select Name,type,Protocol -expandproperty Initiators And now my initiators are blank... upon output.. I'm not quite sure why that is happening.. I see them their in $igroup, so why when I try to parse them So, then I realize that we need to change this line Write-Host "`t`tinitiators: " $i.initiators $iinitiators = $i.initiators to write-host "`tInitiators: " $i.initatornames But then it messes up the output.. What im ultimately looking for is for all the initiators to be on the same line separate by a space so then I can work with the output. any guidance or direction would be great. thx
... View more
I echo what Eric suggests, but if you want to look for read-only volumes you can do this. Get-NaVol | where {$_.state -eq "online" -and $_.raidstatus -match "read-only"}
... View more
Clinton - He bring's up a good point, I read the man page, I don't see any options in cifs to run "resetdc" would you have to connect to the filer via https and then have this code $cifs = get-nacifs if ($cifs.DCConnectoin -eq $null) { invoke-nassh -command "cifs resetdc" }
... View more
You gotta give us a little here. Do you have Powershell experience? Do you know how to connect to filers via powershell? Do you have ONtap powershell module installed?
... View more
Last updated for the day... I forgot the most important part.. disk ID numbers. Function Diskinfo { foreach ($disk in $shelf) { $diskname = $disk.name Write-host " Disk ID:" $diskname out-file $outfile -inputobject " Disk ID: $diskname " -append } } if ($shelf -ne $null) #Call function disk info { diskinfo }
... View more
Well, here is a little addition.. Not quite thrilled with it. Foreach ($d in $disks) { Write-host " Disks: " $d.name } So.. What's interesting is i'm specifically looking for issues on channel 1b/2b. But when I run your script it's telling me way too much information for shelf 3. I'll keep playin around..
... View more
Ashley - Great job.. I'm diggin yours... I like the formatting of it a lot better than mine.. What we should do is add the disk ID numbers, so for example it could say Shelf 1: Disks 1a.10 1a.11 1a.22 etc...
... View more
Eric, Thx for the input as usual... Im playing around with it, but not quite getting exactly what I want.. maybe I should group my output by aggregate and filer... Here's the last line I put in $vols | Select Name,State,Aggregate | Ft -groupby @{E = {$_.aggregate};Label="Aggregate"} -autosize Sort of gives me an overall picture of ok, disks on a specified channel contain these disks, which are part of these aggregates, and here's the volume and the status.... I will keep playin around with it.
... View more
So, i'm at it again... Just playing around and thinking of things I can mess around with and we ran across an issue where we had specific shelf issues in our environment and I wanted to know immediately what volumes were affected. Yah, I can go to my autosupports and backtrack through aggregates, but that's not fun... So, I'm just messing around with a simple query on the disk but i'm having trouble getting the entire picture... Here's where i'm at so far.. $hosts = @("filer1a","filer1b") $hosts | % { Write-host Connecting to Filer: $_ $c = connect-nacontroller $_ $shelf = get-nadisk | ? {($_.name -like "*1b*" -or $_.name -like "*2b*") -and $_.shelf -eq "3" -and $_.aggregate -ne $null} $shelf | Ft -groupby @{E ={$C};Label="Filer"} -autosize } Tthat will give me a clear picture of which filer owns the disks on channel 1b/2b shelf 3, but I want to turn this into what volumes are part of this... My powershell skills are just not taking me to where I need to be at this moment, but i'm giving it a shot. I know the get-nadisk has an aggregate property and I planned on looping that into this get-navol -aggregate $_.aggregate, but i'm having trouble putting it all together.. I need to understand that $shelf should have all the properties and why can't I just do something like $shelf.aggregate. Can someone point me in the right direction... Thanks
... View more
Well you can use the below.. This is what i use as of today gc $hostfile | % { $C = Connect-NaController $_ $snapMirrors = Get-NaSnapmirror | Where-Object {$_.lagTime -gt $lagtimeseconds} if ($snapMirrors -ne $null) { $snapMirrors | ft @{expression={$C};Label="Filer";Width=10},@{expression={$_.sourcelocation};Label="Source";Width=20}` ,@{expression={$_.destinationlocation};Label="Destination Location";Width=20},@{expression={$_.state};Label="Current State";Width=20}` ,@{N='Current Lag Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LagTimeTS.days, $_.LagTimeTS.Hours, $_.LagTimeTS.Minutes, $_.LagTimeTS.Seconds}}` ,@{expression={ConvertTo-FormattedNumber $_.transferprogress DataSize "0.0"};Label="Current Progress";Width=20}` ,@{expression={ConvertTo-FormattedNumber $_.lasttransfersize Datasize "0.0"};Label="Last Transfer size";Width=20} -autosize ` | Out-String -Width 4096 | Out-File $totaloutfile -append } }
... View more
You gotta give me a little more information here.... You can query based on volume name if you want, but do all your filers that you want have the same name. You can do something like get-navol | ? {$_.name -like "*nameyouwant*"} | get-nasnapmirror Or you can filter get-nasnapmirror or you can do a where-object on $_.destination ..
... View more
Yup beam, that's it.. damn, I shoulda dug through the properties deeper with get-member.. So.. Now, let's say I want to edit the default output of the cmdlet. Is that even advisable?
... View more