<# .SYNOPSIS This will activate and deactivate Nvivio 11 with detection methods to ensure the action has been completed correctly. .LINK Author:.......http://www.linkedin.com/in/rileylim .EXAMPLE To activate Nvivo. PowerShell.exe -ExecutionPolicy ByPass -File Manage-NvivoLicence.ps1 .EXAMPLE To deactivate Nvivo. PowerShell.exe -ExecutionPolicy ByPass -File Manage-NvivoLicence.ps1 -Remove #> Param([Switch]$Remove) $DebugPreference = 'SilentlyContinue' #SilentlyContinue|Continue $warningpreference = 'SilentlyContinue' #SilentlyContinue|Continue $WaitTimer = 7 #In secounds, will wait until trying again $MaxAttempts = 5 #Max tries until failing with error code 1 $Count = $null #If testing manually this will flash $Count $Nvivo = "$env:ProgramFiles\QSR\NVivo 11\NVivo.exe" #Chnage this to where the Nvivo exe is located $Licence = 'NVT11-00000-00000-00000-00000' #Nvivo product key/licence If ($Remove -eq $true) {$Count = $null Write-Debug 'Removing licence.' Do {$String = & $Nvivo -deactivate | Out-String $BreakOut = $String.Contains('No activated license key exists to deactivate.') Write-Debug "Removing licence `$String value is: $String" Write-Debug "Removing licence `$BreakOut value is: $BreakOut" Start-Sleep $WaitTimer $Count = $Count + 1 Write-Debug "The `$Counter vlue is: $Count" If ($Count -eq $MaxAttempts) {Write-Debug "The `$Count has reached `$MaxAttempts of $MaxAttempts" Write-Warning "Exiting with error code!" Exit 1}} Until($BreakOut -eq $true) Exit 0} Else{$Count = $null Write-Debug 'Adding Nvivo licence.' Do {$String = & $Nvivo -i $Licence | Out-String $BreakOutA = $String.Contains('Successfully added license key.') $BreakOutB = $String.Contains('Unable to replace the license key. The new key is invalid.') Write-Debug "Adding licence `$String value is: $String" Write-Debug "Adding licence `$BreakOut value is: $BreakOut" Start-Sleep $WaitTimer $Count = $Count + 1 Write-Debug "The `$Counter vlue is: $Count" If ($Count -eq $MaxAttempts) {Write-Debug "The `$Count has reached `$MaxAttempts of $MaxAttempts" Write-Warning "Exiting with error code!" Exit 1}} Until($BreakOutA -or $BreakOutB -eq $true) $Count = $null Write-Debug 'Activating Nvivo.' Do {$String = & $Nvivo -a Registration.xml | Out-String $BreakOutA = $String.Contains('Your license has now been activated.') $BreakOutB = $String.Contains('License key already activated.') Write-Debug "Activating licence `$String value is: $String" Write-Debug "Activating licence `$BreakOut value is: $BreakOut" Start-Sleep $WaitTimer $Count = $Count + 1 Write-Debug "The `$Counter vlue is: $Count" If ($Count -eq $MaxAttempts) {Write-Debug "The `$Count has reached `$MaxAttempts of $MaxAttempts" Write-Warning "Exiting with error code!" Exit 1}} Until($BreakOutA -or $BreakOutB -eq $true) Exit 0} |
View inventory records anonymously contributed by opt-in users of the K1000 Systems Management Appliance.