Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Change the rendition profile on several folders with the same name at once with Set-PWFolderRenditionProfile?
    • Sign In

    • State Verified Answer
    • Replies 6 replies
    • Answers 1 answer
    • Subscribers 67 subscribers
    • Views 1923 views
    • Users 0 members are here
    • powershell
    • Set-PWFolderRenditionProfile

    Change the rendition profile on several folders with the same name at once with Set-PWFolderRenditionProfile?

    Erik Holmqvist
    Offline Erik Holmqvist over 5 years ago

    Tried to change to rendition profile for several folders with a powershell script but with no success. 

    Tried something very similar to what I have for changing several views at once, which looks like this:

    ## IMPORT PWPS_DAB.DLL
    Import-Module -Name "PWPS_DAB" -DisableNameChecking
    
    ## Choose folder and its subfolder which it searching in
    $TargetFolder = "Project\"
    
    ## Specify which folder that you want to change view
    $ThisFolder = "Drawings"
    
    
    ## Choose which view you want to change to
    $ThisView = "Ritningsvy"
    
    ############################################ SCRIPT ############################################################
    New-PWLogin -UseGui 
    $Folders = get-pwfolders -folderpath $TargetFolder -Slow | where-object -Property "Name" -Like -Value $ThisFolder
    $Folders | Set-PWFolderView -View $ThisView
    ############################################ SCRIPT ############################################################
    
    ## Logging out
    Undo-PWLogin

    Is it possible to do something similar with Set-PWFolderRenditionProfile?

    Thanks!

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Thu, Mar 22 2018 2:28 PM +3 suggested
      I have updated each of the rendition cmdlets to accept inputfolders from the pipeline. Get-PWFolderRenditionProfile, Set-PWFolderRenditionProfile and Remove-PWFolderRenditionProfile. Look for them in…
    • Brian Flaherty
      Offline Brian Flaherty Thu, Mar 22 2018 11:43 AM +1
      Currently, the Set-PWFolderRenditionProfile does not accept pipeline input. This can be added. Look for it in a future release of the PWPS_DAB module. At this point, you could use a foreach loop to apply…
    • Kevin van Haaren
      Offline Kevin van Haaren Thu, Mar 22 2018 2:10 PM +1 verified
      this worked for me. I changed up some things to my own preferences # allow -vebose/-debug parameters [CmdletBinding()] param() Import-Module -Name "PWPS_DAB" -DisableNameChecking ## Choose folder…
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Mar 22 2018 11:43 AM

      Currently, the Set-PWFolderRenditionProfile does not accept pipeline input. This can be added. Look for it in a future release of the PWPS_DAB module.

      At this point, you could use a foreach loop to apply to each folder.

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Erik Holmqvist
      0 Offline Erik Holmqvist Thu, Mar 22 2018 11:49 AM in reply to Brian Flaherty

      Yeah now that you mention it, it said something about dont accept pipeline input :)

      Acutally tried to it with a foreach loop, but my knowledge about powershell is quite basic so I gave up. Do you mind giving me some guidance in the right directions? thanks!

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin van Haaren
      +1 Offline Kevin van Haaren Thu, Mar 22 2018 2:10 PM

      this worked for me. I changed up some things to my own preferences Slight smile

      # allow -vebose/-debug parameters
      [CmdletBinding()]
      param()
      
      Import-Module -Name "PWPS_DAB" -DisableNameChecking
      
      ## Choose folder and its subfolder which it searching in
      $RootFolder = "Users\KvanHaaren"
      
      # ANY sub-folder of $RootFolder with a name listed below will have
      # its Rendition Profile changed. No matter how deep under $RootFolder.
      $ChangeFolders = @("CADDLib","ics")
      
      ## Choose which view you want to change to
      $NewRendition = "Project B&W"
      
      New-PWLogin -UseGui 
      
      $Folders = get-pwfolders -folderpath $RootFolder -Slow | where-object -Property "Name" -In -Value $ChangeFolders
      
      # Loop through all found folders
      foreach ($ThisFolder in $Folders) {
      	write-verbose "Changing rendition profile on $ThisFolder.FullPath"
      	try {
      		Set-PWFolderRenditionProfile -FolderPath $ThisFolder.FullPath -ProfileName $NewRendition
      	} catch {
      		Throw "Error occured changing rendition profile on $ThisFolder.FullPath`n`n$($Error[0])"
      	}
      }
      
      ## Logging out
      Undo-PWLogin
      

      I always start scripts with

      [CmdletBinding()]

      param()

      so I can use -verbose and -debug options from the command line.

      I changed the $TargetFolder to an array of folder names (and the variable name to $ChangeFolders.  You can list multiple folders here and it will find every folder with that name under $RootFolder.

      Be careful of this, it will match in sub-sub-folders too. so @("folderA","folder2") will match all below:

      Root\FolderA

      Root\Folder2

      Root\FolderC\Folder2

      Root\FolderD\FolderC\Folder2

      the where command now uses -In instead of -Like. This allows it to match any folder in the $ChangeFolders array, however you lose your ability to use wildcards in folder names.

      ForEach will set the variable $ThisFolder to a folder from the $Folders list. No set order is followed, you just know each object will pass through the loop.

      Using the FullName property for the Set-PWFolderRendtionProfile will get around it not supporting pipeline objects.

       

      Answer Verified By: Erik Holmqvist 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Mar 22 2018 2:28 PM

      I have updated each of the rendition cmdlets to accept inputfolders from the pipeline.

      Get-PWFolderRenditionProfile, Set-PWFolderRenditionProfile and Remove-PWFolderRenditionProfile. Look for them in the next release of the PWPS_DAB module.

      • Cancel
      • Vote Up +3 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    • Erik Holmqvist
      0 Offline Erik Holmqvist Thu, Mar 22 2018 2:59 PM in reply to Kevin van Haaren

      This is awesome Kevin, it works great! Thanks for that! Slight smile

      And cheers for adding -verbose output, was trying to add that to my own scripts so I could get some feedback from the script, now I know better how it can be used.  Thumbsup

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    >

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies