Skip to content

Instantly share code, notes, and snippets.

@ddemeyer
Last active March 31, 2017 16:19
Show Gist options
  • Save ddemeyer/9e2d62b1590053aa917e6f01fe3763c0 to your computer and use it in GitHub Desktop.
Save ddemeyer/9e2d62b1590053aa917e6f01fe3763c0 to your computer and use it in GitHub Desktop.
ISHRemote code samples on doing an Administrator's Upgrade, creating a project based UserGroup with a folder structure on Knowledge Center Content Manager (= LiveContent Architect = Trisoft InfoShare)
#
# SDL Belgium/ddemeyer
# 20170329
#
# POWERSHELL REMARK #1...
# If you get "...cannot be loaded because the execution of scripts is disabled on this system."
# Then you are running Restricted, so then execute as an Administrator
# Set-ExecutionPolicy unrestricted
# POWERSHELL REMARK #2...
# If you can't load the editor 'ise' and get a "Cannot resolve alias 'ise'..." message.
# You can execute the following two lines in order to fix this on Windows 2008R2 and 7.
# Import-Module ServerManager
# Add-WindowsFeature PowerShell-ISE
# POWERHSELL REMARK #3...
# On release 9.0.0/9.2.0/10.0.0 we only install a 32-bit version of the Oracle.DataAccess component.
# This means that you have to provide a 32-bit host (powershell) to allow the script to
# run on Oracle. Can be done by "%WINDIR%\syswow64\windowspowershell\v1.0\powershell.exe"
#
# REQUIRES
# ISHRemote, see https://github.com/sdl/ISHRemote, to install
# Install-Module ISHRemote -Repository PSGallery -Scope CurrentUser -Force
#
# EXAMPLE
# .\Prepare-BetaCorner.ps1 -WsBaseUrl "https://example.com/infosharewsdita/" -ProjectCornerName "CustomerOne"
#
# $cred = Get-Credential "Admin"
# .\Prepare-BetaCorner.ps1 -WsBaseUrl "https://example.com/ISHWS2/" -PSCredential $cred -IShCDFolderPath "c:\ishcd\20170321.CD.InfoShare.13.0.2721.0.Trisoft-DITA-OT\"
# .\Prepare-BetaCorner.ps1 -WsBaseUrl "https://example.com/ISHWS2/" -PSCredential $cred -ProjectCornerName "SDLDevOps"
#
#
# PARAM statement must be first non-comment, non-blank line in the script
#
[CmdletBinding(DefaultParameterSetName='Secret')]
Param(
[parameter(Mandatory=$true)]
$WsBaseUrl,
[parameter(Mandatory=$false)]
$PSCredential = $null,
$IShCDFolderPath = $null,
$DitaDeliveryOutputFormatName = $null,
$DitaDeliveryServerURI = 'https://example.com/',
$DitaDeliveryClientID = 'user',
$DitaDeliveryClientSecret = 'password',
$DitaDeliveryPrefix = 'ish',
$DitaDeliveryTopologyURIs = '',
$ProjectCornerName = $null,
$ProjectCornerUserCount = 1
)
#
# GLOBAL SETTINGS
#
Write-Verbose "`r`nSetting preferences..."
$DebugPreference = "SilentlyContinue" # Continue or SilentlyContinue
$VerbosePreference = "SilentlyContinue" # Continue or SilentlyContinue
$ProgressPreference= "SilentlyContinue" # Continue or SilentlyContinue
$WarningPreference = "Continue" # Continue or SilentlyContinue or Stop
##############################################################
### MAIN ###################################################
##############################################################
$ishSession = New-IshSession -WsBaseUrl $WsBaseUrl -PSCredential $psCredential
#
# Administrator's upgrade...
#
if (($IShCDFolderPath -ne $null) -and (Test-Path -LiteralPath $IShCDFolderPath))
{
$EnterViaUIFolder = Join-Path $IShCDFolderPath "Websites\Author\EnterViaUI\"
Set-IshSetting -IshSession $ishSession -FieldName "FISHCHANGETRACKERCONFIG" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLChangeTrackerConfig.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FISHPLUGINCONFIGXML" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLPluginConfig.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FTRANSLATIONCONFIGURATION" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLTranslationConfiguration.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FISHWRITEOBJPLUGINCFG" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLWriteObjPluginConfig.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FISHBACKGROUNDTASKCONFIG" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLBackgroundTaskConfiguration.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FISHEXTENSIONCONFIG" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLExtensionConfiguration.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FINBOXCONFIGURATION" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLInboxConfiguration.xml")
Set-IshSetting -IshSession $ishSession -FieldName "FISHPUBLISHPLUGINCONFIG" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLPublishPluginConfiguration.xml")
Add-IshLovValue -IshSession $ishSession -Description "Translation Review" -Label "Translation In Review" -LovId "DSTATUS"
Set-IshSetting -IshSession $ishSession -FieldName "FSTATECONFIGURATION" -FilePath (Join-Path $EnterViaUIFolder "Admin.XMLStatusConfiguration.xml")
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "SDL Knowledge Center" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "SDL Web" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "SDL TMS" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "SDL WorldServer" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Acme Phones" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Acme Printers" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Acme Laptops" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Amazing Hardware" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Amazing Software" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTFAMILYNAME" -Label "Amazing Tech Writers" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL LiveContent 2014 (11.0.0)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL LiveContent 2014 SP1 (11.0.1)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL LiveContent 2014 SP2 (11.0.2)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL LiveContent 2014 SP3 (11.0.3)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL Knowledge Center 2016 (12.0.0)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL Knowledge Center 2016 SP1 (12.0.1)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL Knowledge Center 2016 SP2 (12.0.2)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "SDL Knowledge Center 2016 SP3 (12.0.3)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "Acme Phone 330 (1.1)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "Acme Phone 660 (10.2)" -Description "Generated by Prepare-ProjectCorner.ps1"
Add-IshLovValue -IshSession $ishSession -LovId "DPRODUCTRELEASENAME" -Label "Acme Phone 990 (9.3)" -Description "Generated by Prepare-ProjectCorner.ps1"
}
if ($DitaDeliveryOutputFormatName -ne $null)
{
$ishRequestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "FISHOUTPUTFORMATNAME" -Level "None"
$outputFormatExists = Find-IshOutputFormat -IshSession $ishSession -ActivityFilter "None" -RequestedMetadata $ishRequestedMetadata |
Where-Object {(Get-IshMetadataField -IshSession $ishSession -IshObject $_ -Name "FISHOUTPUTFORMATNAME" -Level None) -eq $DitaDeliveryOutputFormatName}
if (! $outputFormatExists)
{
$ishMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FISHRESOLUTIONS" -Level "none" -ValueType Element -Value "VRESLOW" |
Set-IshMetadataField -IshSession $ishSession -Name "FSTYLEPROCESSOR" -Level "none" -Value "DITA-OT\InfoShare" |
Set-IshMetadataField -IshSession $ishSession -Name "FDITAOTTRANSTYPE" -Level "none" -Value "ishditadelivery" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHSINGLEFILE" -Level "none" -ValueType Element -Value "FALSE" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHKEEPFIXEDATTRIBUTES" -Level "none" -ValueType Element -Value "TRUE" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHKEEPDTDSYSTEMID" -Level "none" -ValueType Element -Value "TRUE"|
Set-IshMetadataField -IshSession $ishSession -Name "FISHPUBRESOLVEVARIABLES" -Level "none" -ValueType Element -Value "TRUE" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHCLEANUP" -Level "none" -ValueType Element -Value "TRUE" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHINCLUDEMISSINGOBJS" -Level "none" -ValueType Element -Value "FALSE" |
Set-IshMetadataField -IshSession $ishSession -Name "FISHDITADLVRSERVERURI" -Level "none" -Value $DitaDeliveryServerURI |
Set-IshMetadataField -IshSession $ishSession -Name "FISHDITADLVRCLIENTID" -Level "none" -Value $DitaDeliveryClientID |
Set-IshMetadataField -IshSession $ishSession -Name "FISHDITADLVRCLIENTSECRET" -Level "none" -Value $DitaDeliveryClientSecret |
Set-IshMetadataField -IshSession $ishSession -Name "FISHDITADLVRIDPREFIX" -Level "none" -Value $DitaDeliveryPrefix |
Set-IshMetadataField -IshSession $ishSession -Name "FISHDITADLVRTOPOLOGYURIS" -Level "none" -Value $DitaDeliveryTopologyURIs
$ishOutputFormatObject = Add-IshOutputFormat -IshSession $ishSession -Name $DitaDeliveryOutputFormatName -EDT "EDTZIP" -Metadata $ishMetadata
}
}
if ($ProjectCornerName -ne $null)
{
# UserGroup
$metadata = Set-IshMetadataField -IshSession $ishSession -Name "FDESCRIPTION" -Level None -Value "Description of $ProjectCornerName"
$ishUserGroupObject = Add-IshUserGroup -IshSession $ishSession -Name $ProjectCornerName -Metadata $metadata
# Give current administrator user (probably 'Admin') access to the freshly created UserGroup, by appending
$ishMyUserObject = Get-IshUser -IshSession $ishSession -RequestedMetadata (Set-IshRequestedMetadataField -IshSession $ishSession -Name "FUSERGROUP" -Level None -ValueType Element)
$ishMyUserGroups = Get-IshMetadataField -IshSession $ishSession -IshObject $ishMyUserObject -Name "FUSERGROUP" -Level None -ValueType Element
$ishMyUserGroups = $ishMyUserGroups + $ishSession.Seperator + $ishUserGroupObject.IshRef
$ishMyUserObject = $ishMyUserObject |
Set-IshMetadataField -IshSession $ishSession -Name "FUSERGROUP" -Level None -ValueType Element -Value $ishMyUserGroups |
Set-IshUser -IshSession $ishSession
# n Users with rights
for ($i = 1; $i -le $ProjectCornerUserCount; $i++)
{
$userName = ($ProjectCornerName + "User" + $i)
$metadata = Set-IshMetadataField -IshSession $ishSession -Name FISHUSERLANGUAGE -Level None -ValueType Element -Value "VLANGUAGEEN" |
Set-IshMetadataField -IshSession $ishSession -Name FUSERGROUP -Level None -ValueType Element -Value $ishUserGroupObject.IshRef |
Set-IshMetadataField -IshSession $ishSession -Name FISHUSERROLES -Level None -ValueType Element -Value "VUSERROLEAUTHOR, VUSERROLEREVIEWER" |
Set-IshMetadataField -IshSession $ishSession -Name PASSWORD -Level None -Value $ProjectCornerName
$ishUserObject = Add-IshUser -IshSession $ishSession -Name $userName -Metadata $metadata
}
# Root Folder and basic folder structure
$userGroupWrite = $ishUserGroupObject.IshRef
$userGroupReads = @($ishUserGroupObject.IshRef, "VUSERGROUPDEFAULTDEPARTMENT")
$ishRootFolderObject = Add-IshFolder -IShSession $ishSession -ParentFolderId (Get-IshFolder -IShSession $ishSession -FolderPath "\General\").IshFolderRef -FolderType ISHNone -FolderName $ProjectCornerName -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
$parentFolderId = $ishRootFolderObject.IshFolderRef
Add-IshFolder -IshSession $ishSession -ParentFolderId $parentFolderId -FolderType ISHIllustration -FolderName "Images" -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
Add-IshFolder -IshSession $ishSession -ParentFolderId $parentFolderId -FolderType ISHLibrary -FolderName "Libs" -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
Add-IshFolder -IshSession $ishSession -ParentFolderId $parentFolderId -FolderType ISHModule -FolderName "Topics" -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
Add-IshFolder -IshSession $ishSession -ParentFolderId $parentFolderId -FolderType ISHMasterDoc -FolderName "Maps" -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
Add-IshFolder -IshSession $ishSession -ParentFolderId $parentFolderId -FolderType ISHPublication -FolderName "Pubs" -OwnedBy $userGroupWrite -ReadAccess $userGroupReads
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment