This script is run on the wfa server (my laptop in my case). It loads the WFA libraries and adds the default functions
- Get-WfaLogger
- Get-WfaCredentials
- Connect-WfaCluster
- Connect-WfaController
- Set-WfaCommandProgress
When you open your powershell, just run it once, and you are ready to start testing.
Note at the top that it will set the current directory to my desktop (change it to what your default testing directory is)
try{ cd 'C:\Program Files\NetApp\WFA\PoSH\' . '.\profile.ps1' Write-Host -ForegroundColor Cyan "Found a local wfa server, loading the profile..." }catch{ Write-Host -ForegroundColor Magenta "You don't seem to have WFA installed... it's recommended to install WFA locally, so we can load the WFA profile." } cd 'c:\users\mirko\desktop' function Get-WFALogger{ param( [switch] $Info, [switch] $Error, [switch] $Warn, [string] $Message ) if($Info){ Write-Host $Message -foregroundColor green } if($Warn){ Write-Host $Message -ForegroundColor yellow } if($Error){ Write-Host $Message -ForegroundColor red } } function Get-WfaCredentials($hostname){ if($hostname -eq "be-pslab.local"){ $u = "mirko" $p = "Netapp12" } if($hostname -eq "localhost"){ $u = "admin" $p = "Netapp12" } if($hostname -eq "slash.local"){ $u = "administrator" $p = "Netapp12" } # add more entries if needed # if($hostname -eq .... $secpasswd = ConvertTo-SecureString $p -AsPlainText -Force return New-Object System.Management.Automation.PSCredential ($u, $secpasswd) } function Get-WfaInputPassword($EncryptedPassword){ return $EncryptedPassword } function Connect-WfaCluster($Node,$Vserver){ if($Vserver){ Connect-NcController -Name $Node -Vserver $Vserver }else{ Connect-NcController -Name $Node } } function Connect-WfaController($Array,$Vfiler){ if($Vfiler){ Connect-NaController -Name $Array -Vfiler $Vfiler }else{ Connect-NaController -Name $Array } } function Set-WfaCommandProgress($Total,$Current,$ProgressPercentage,$Note){ if($ProgressPercentage -eq 100){ Write-Progress -Activity 'Wfaloop' -Completed $global:wfaloopcomplete=$true } else{ Write-Progress -Activity 'Wfaloop' -status ("$Current" + "/" + "$Total") -percentComplete $ProgressPercentage -currentOperation $Note } } function Get-WfaRestParameter($name){ switch($name){ "userName" {"dummy_user"} "workflowName" {"dummy_workflow"} "workflowId" {123} "jobId"{ 987 } } } # DATASOURCE LOGGING FUNCTIONS # LOG INFO function LogInfo($t){ Write-Host $t -ForegroundColor Yellow } # LOG DEBUG function LogDebug($t){ Write-Host $t -ForegroundColor Cyan } # LOG WARN function LogWarn($t){ Write-Warning $t } # LOG ERROR function LogError($t){ Write-Host $t -ForegroundColor Red } # LOG FATAL (throws error & exit) function LogFatal($t){ Write-Host $t -ForegroundColor Magenta }
I tried to run this, and I'm getting errors just trying to run the ".\profile.ps1". Any idea what I'm doing wrong? I have WFA installed to my E: drive, but the profile script seems to account for that.
ReplyDeleteIt spits out a ton of errors, but they are all similar to this:
Import-Module : The following error occurred while loading the extended type data file: , E:\Program Files\NetApp\WFA\PoSH\Modules\DataONTAP\DataONTAP.Type.ps1xml(1376) : Error in type "DataONTAP.Types.Iscsi.IscsiPortalListEntryInfo": The "Type" node must have "Members", "TypeConverters", or "TypeAdapters".
E:\Program Files\NetApp\WFA\PoSH\Modules\DataONTAP\DataONTAP.Type.ps1xml(1367) : Error in type "DataONTAP.PowerShell.SDK.Cmdlets.HyperV.MbrPartition": The "Type" node must have "Members", "TypeConverters", or "TypeAdapters".
Thanks!
That doesnt sound great. Pm me. And we will have a look at it. Obviously you need to repace c: with e: But i figure you did that. So you seem to have issues with running profile.ps1. One thing i probably forgot was dataontap. Did you have dataontap installed? My laptop does. It think i need to add a line where i import dataontap from the wfa path. My laptop uses the local dataontap. I will debug on a fresh wfa server and fix it if needed!
ReplyDeleteThanks for your response. I think I figured it out though. My Powershell profile was Importing the DataOnTap module. Once I renamed my Powershell profile, your script worked fine. Thanks again!
ReplyDelete