en-US/about_ConfluencePS.help.txt

TOPIC
    about_ConfluencePS

SHORT DESCRIPTION
    Interact with your Confluence wiki environments from PowerShell.
    Create, get, edit, and delete many pages at once.

    Comment-based help is provided for all cmdlets:

        Get-Help Get-WikiPage -Full

LONG DESCRIPTION
    Confluence is a wiki product from Atlassian.
    ConfluencePS is a module provided to interact with Confluence's REST API.

    ConfluencePS was introduced to solve two problems:
    1) Making it easy to perform the same change on many wiki pages
    2) Automating documentation updates

  GETTING STARTED
    Import-Module ConfluencePS
    Set-WikiInfo -BaseURI 'https://mywiki.company.com'

    Unless supplying the credentials (-Credential $cred), you will then be
    prompted for a username/password to connect to the wiki instance.
    The connection is established via basic header authentication, and
    Set-WikiInfo needs to be run at the beginning of each PowerShell session.

  DISCOVERING YOUR ENVIRONMENT
    To view all spaces, run the following command:

        Get-WikiSpace

    To view all pages in a specific space, you can use the pipeline:

        Get-WikiSpace -Name Demo | Get-WikiPage -Limit 1000

    Note that the REST API will limit your results in different ways.
    
    For example, if you do not supply the -Limit parameter,
    only 25 pages will be returned, and probably not in the order you choose.
    You may also find that 500 or 1000 is the maximum result supported,
    and any higher numbers will just return 500/1000 results anyway.

    You can fetch a page's content with the following command:

        Get-WikiPage -Title 'Contacts' -Limit 1000 | Get-WikiPage -Expand

    This will find any page matching "*contacts*", and then use the PageID(s)
    found to fetch the page body and version as well. If you don't already know
    the PageID, it should be done this way because -Expand drastically reduces
    the amount of pages the API returns, regardless of the -Limit you specify.

  PRIMARY USE CASES

    1) Making it easy to perform the same change on many wiki pages

    To apply a new label to all pages matching specified criteria:

        Get-WikiPage -Title 'Azure' -Limit 1000 | New-WikiLabel -Label azure

    To delete pages with the label "test":

        Get-WikiLabelApplied -Label test -Limit 1000 | Remove-WikiPage -WhatIf

    Use -WhatIf first to be sure only intended pages will be affected,
    then run the command again without the -WhatIf parameter.

    2) Automating documentation updates

    My use case involved wanting a page for each VM with up-to-date specs
    and purpose, because the whole team did not have access to the VM
    management environment.

    To accomplish this, assume there is a nightly script that pulls the
    following VM info and stores it in a CSV (or database/whatever):

        Name, IP, Dept, Purpose

    That script also populates a TXT file with names of VMs whose values
    changed in the last 24 hours.

    With this info, you can have another nightly script connect to the wiki
    instance, see if anything has changed, and update pages accordingly with
    something like the following:

        $CSV = Import-Csv .\vmlist.csv
        ForEach ($VM in (Get-Content .\changes.txt)) {
            $Table = $CSV | Where Name -eq $VM | ConvertTo-WikiTable | Out-String
            $Body = $Table | ConvertTo-WikiStorageFormat

            If ($ID = (Get-WikiPage -Title "$($VM.Name)" -Limit 500).ID) {
                # Current page found. With the ID, get the expanded result
                $PageExists = Get-WikiPage -PageID $ID -Expand
                $PageExists | Set-WikiPage -ParentID 123456 -Body $Body
            } Else {
                New-WikiPage -Title "$($VM.Name)" -Body $Body -ParentID 123456
            }
        }

    You want more error-handling, and probably more stuff on your wiki page.
    But that's the basic idea :)

NOTE
    Support for the full REST API has not been finished,
    and will be supplemented as my personal need arises and time permits.

SEE ALSO
    The project on Github:
        https://github.com/brianbunke/ConfluencePS
    Confluence's REST API documentation:
        https://docs.atlassian.com/atlassian-confluence/REST/latest/

KEYWORDS
    Confluence, Atlassian, Wiki