Hi Vikramjeet,
Here is the source code from the original source file:
param
(
[parameter(Mandatory=$true, HelpMessage="Cluster IP address")]
[string]$Cluster,
[parameter(Mandatory=$true, HelpMessage="Storage Virtual Machine where User exists")]
[string]$svmname,
[parameter(Mandatory=$false, HelpMessage="Create a Audit log for updates")]
[bool]$createauditlog=$false,
[parameter(Mandatory=$false, HelpMessage="File path to text file")]
[string]$auditfilepath=$("c:\audit\"+ $Cluster +"-"+ $svmname + "-PasswordChange-"+(get-date).ToString("yyyyMMdd-hhmmss")+'.txt')
)
#Start here
Connect-WfaCluster $Cluster
$credentials = get-wfacredentials -host newpassword
$userinfo = Get-NcUser $credentials.username -Vserver $svmname -AuthMethod password
if ($auditfilepath)
{
foreach($line in $userinfo)
{
(get-date).ToString("yyyyMMdd-hhmmss")+":"+$line |Out-File -Append -FilePath $auditfilepath
}
}
#Validate user exists
if ( $userinfo.Count -lt 1)
{
if ($auditfilepath)
{
(get-date).ToString("yyyyMMdd-hhmmss")+":Unable to find a valid user account for $Credentials.UserName on $svmname"|Out-File -Append -FilePath $auditfilepath
}
throw "Unable to find a valid user account for $UserName on $svmname"
}
try
{
Set-NcUserPassword -credential $credentials -VserverContext $svmname -Verbose
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
if ($auditfilepath)
{
(get-date).ToString("yyyyMMdd-hhmmss")+":Password for user $Credentials.Username was not Successfully updated for $svmname on $cluster ”|Out-File -Append -FilePath $auditfilepath
$FailedItem|Out-File -Append -FilePath $auditfilepath
$ErrorMessage|Out-File -Append -FilePath $auditfilepath
}
throw "$ErrorMessage"
break
}
finally
{
Get-WFALogger -Info -message $("the password change was successful for $svmname on cluster $Cluster")
if ($auditfilepath)
{
(get-date).ToString("yyyyMMdd-hhmmss")+":Password for user $Credentials.Username was Successfully updated for $svmname on $cluster ”|Out-File -Append -FilePath $auditfilepath
}
}
For future reference I recommend using this PowerShell Module created by @mirko
http://www.wfaguy.com/2017/02/change-version-of-dar-file.html
It is a powershell module that will enable you to covert between WFA versions. For example:
PS C:\Scripts\PowerShell\Projects\WFA\ReversionWFA> import-module .\ReversionWfa.psm1
PS C:\Scripts\PowerShell\Projects\WFA\ReversionWFA> Set-WfaVersion .\close_locked_file.dar -Version 4.2 -RemoveDependencies
DOWNGRADING DAR-FILES TO VERSION 4.2
MAJOR : 4
MINOR : 2
Processing .\close_locked_file.dar
Already lower [4.1.0.0.2]
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive C:\Scripts\PowerShell\Projects\WFA\ReversionWFA\Wfa Versions 4.2\close_locked_file_(4.1).dar
Compressing CommandDefinition_044c8f55_07b5_4b01_ba86_996807140fa9.xml
Compressing META-INF\MANIFEST.MF
Compressing TabularWorkflow_bfd2c0a6_fd2b_4907_ba18_e7958b82ea98.xml
Everything is Ok
Finished
Find your new dar files in [C:\Scripts\PowerShell\Projects\WFA\ReversionWFA\Wfa Versions 4.2]
- Download the "ReversionWFA" powershell module: http://www.wfaguy.com/2017/02/change-version-of-dar-file.html
- Extract the module
- Open a powershell session
- Browse to the path where you extracted the module
- Run Import-Module .\ReversionWfa.psm1
- Run Set-WfaVersion and provide cmdlet parameters (EG file, WFA version, remove dependancies, force etc)
- Import the updated .dar file into WFA.
Note: This module only supports conversion from WFA 3.0 and above. As the .dar file you wanted to convert was developed using WFA 2.X I had to import it into an old version of WFA 2.X in my lab, export it then import into WFA 3.X then use the above process to covert it WFA 4.X (painful but possible 🙂
Hope this helps
/Matt
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.