[System.Threading.Thread]::CurrentThread.CurrentCulture="en-US" if ($PSVersionTable.PSVersion.Major -le '2') { throw("Minimum PowerShell version required is 3.0") } ###### Create the Logger Configuration WFA ###### #Load the assembley from your dll location $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent $dllLocation=$PSScriptRoot.Substring(0, $($PSScriptRoot.Length - 24)) + "PoSH\Modules\DataONTAP\log4net.dll" [void][Reflection.Assembly]::LoadFrom($dllLocation) #Define your logging pattern. See more about it here: http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html $pattern="%d %w %-5p %c : %m%n" #Reset the log4net configuration [log4net.LogManager]::ResetConfiguration() #Create the Logging file for every single Datasource based on the Hostname. $DSHostName = Get-WfaRestParameter "host" $logFile=$PSScriptRoot.Substring(0, $($PSScriptRoot.Length - 8)) + "\log\" + $DSHostName +".log" New-Item -Path $logFile -type file -Force #Create the log4net config Appender $Appender = new-object log4net.Appender.FileAppender $Appender.File = $logFile $Appender.Layout = new-object log4net.Layout.PatternLayout($pattern) $Appender.Threshold = [log4net.Core.Level]::All $Appender.ActivateOptions() [log4net.Config.BasicConfigurator]::Configure($Appender) #Create Logger for the DataSource Type Name. You can actually put anything $logg = [log4net.LogManager]::GetLogger("[Get All workflows]") ###### Logger is ready ##### $logg.Info("====== Data Source acquisition begins now =======") $workflowFile = "./workflow.csv" New-Item -Path $workflowFile -type file -force $logg.Info($workflowFile) $logg.Info("fsdfdsfsdfsdfdsf") $connectionInfo = @{}; Try { $connectionInfo["host"] = Get-WfaRestParameter "host" $connectionInfo["port"] = Get-WfaRestParameter "port" $connectionInfo["credentials"] = Get-WfaCredentials } catch [System.Exception] { $error = "Error getting data source credentials: $($_.Exception)" Get-WFALogger -message $error -Error Throw "Error getting data source credentials. Please see the log file for more details" } $url = "http://" + $connectionInfo["host"] + ":" + $connectionInfo["port"] + "/wfa-ws/WorkflowService_rpc?wsdl" $logg.Info($url) $proxy = New-WebServiceProxy -Uri $url -Credential $connectionInfo["credentials"] $wf=$proxy.getAllWorkflows() foreach ( $workflow in $wf ) { $workflowid = [int]$workflow.id $workflowName = [string]$workflow.name $workflowUuid = [string]$workflow.uuid #Write this Data to .CSV try { Add-Content $workflowFile ([Byte[]][Char[]] "\N`t$workflowid`t$workflowName`t$workflowUuid`n") -Encoding Byte $logg.Info("Info $workflowid , Name $workflowName, UUID $workflowUuid") } catch { Add-Content $workflowFile ("\N`t$workflowid`t$workflowName`t$workflowUuid`n") $logg.Error("Error $workflowid , Name $workflowName, UUID $workflowUuid") } } #[System.Io.File]::ReadAllText($workflowFile) | Set-Content -Path $vmsFile -Encoding ascii