├── .gitignore ├── AddTypes.ps1 ├── Administration ├── Clear-CflTrash.ps1 ├── Disable-CflAnonymousAccess.ps1 ├── Disable-CflWysiwyg.ps1 ├── Enable-CflAnonymousAccess.ps1 ├── Enable-CflWysiwyg.ps1 ├── Get-CflTrashItem.ps1 ├── Remove-CflTrashItem.ps1 └── Restore-CflTrashItem.ps1 ├── CflSession.cs ├── CflSessionManager.cs ├── Confluence.csproj ├── Confluence.gpState ├── Content ├── Add-CflAttachment.ps1 ├── Add-CflComment.ps1 ├── Add-CflLabel.ps1 ├── Get-CflAttachment.ps1 ├── Get-CflBlogEntry.ps1 ├── Get-CflBookmark.ps1 ├── Get-CflComment.ps1 ├── Get-CflLabel.ps1 ├── Get-CflPage.ps1 ├── Move-CflPage.ps1 ├── New-CflBlogEntry.ps1 ├── New-CflBookmark.ps1 ├── New-CflPage.ps1 ├── Remove-CflAttachment.ps1 ├── Remove-CflComment.ps1 ├── Remove-CflLabel.ps1 ├── Remove-CflPage.ps1 ├── Set-CflPage.ps1 ├── Update-CflBlogEntry.ps1 └── Update-CflPage.ps1 ├── Enter-CflSession.ps1 ├── Exit-CflSession.ps1 ├── Formatting ├── ConvertTo-CflChart.ps1 ├── ConvertTo-CflList.ps1 ├── ConvertTo-CflStorageFormat.ps1 ├── ConvertTo-CflTable.ps1 ├── ConvertTo-CflTablePlus.ps1 ├── Merge-CflChart.ps1 └── Merge-CflTable.ps1 ├── Get-CflSession.ps1 ├── Get-CflSpace.ps1 ├── ImportExport ├── Convert-CflArchiveUser.ps1 ├── Export-CflSite.ps1 ├── Export-CflSpace.ps1 ├── Get-CflArchive.ps1 ├── Get-CflArchiveUser.ps1 ├── Import-CflSite.ps1 ├── Import-CflSpace.ps1 └── Test-CflArchive.ps1 ├── Invoke-CflItem.ps1 ├── New-CflSession.ps1 ├── New-CflSpace.ps1 ├── PageSet.cs ├── Permissions ├── Get-CflSpaceLevelPermission.ps1 └── Get-CflSpacePermission.ps1 ├── Plugins ├── Disable-CflUpmSafeMode.ps1 ├── Enable-CflPlugin.ps1 ├── Enable-CflUpmSafeMode.ps1 ├── Get-CflPlugin.ps1 └── Get-CflUpmSetting.ps1 ├── PoshConfluence.Format.ps1xml ├── PoshConfluence.Types.ps1xml ├── PoshConfluence.psd1 ├── PoshConfluence.psm1 ├── README ├── Remove-CflSession.ps1 ├── Remove-CflSpace.ps1 ├── Search-CflContent.ps1 ├── SpaceManagement └── Get-CflSpaceTrash.ps1 ├── UserManagement ├── Add-CflGroupMember.ps1 ├── Disable-CflUser.ps1 ├── Enable-CflUser.ps1 ├── Get-CflGroup.ps1 ├── Get-CflGroupMember.ps1 ├── Get-CflMemberOf.ps1 ├── Get-CflPageWatch.ps1 ├── Get-CflUser.ps1 ├── Get-CflUserGroup.ps1 ├── New-CflGroup.ps1 ├── New-CflUser.ps1 ├── Register-CflPageWatch.ps1 ├── Remove-CflGroup.ps1 ├── Remove-CflGroupMember.ps1 ├── Remove-CflUser.ps1 ├── Test-CflGroup.ps1 ├── Test-CflUser.ps1 └── Unregister-CflPageWatch.ps1 └── confluence-v2.wsdl /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | _ReSharper.Confluence/* 3 | Confluence/obj/* 4 | Confluence.suo 5 | *.ReSharper.user 6 | *.user 7 | /_ReSharper.Confluence 8 | *.suo 9 | bin 10 | 11 | Confluence.ncrunchsolution 12 | Confluence\bin\Debug*/ -------------------------------------------------------------------------------- /AddTypes.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 2/12/2012 16:35:18 3 | #Script: AddTypes 4 | Add-Type -Path "$psScriptRoot\CflSession.cs", "$psScriptRoot\CflSessionManager.cs", "$psScriptRoot\PageSet.cs" 5 | $proxy = (New-WebServiceProxy $psScriptRoot\confluence-v2.wsdl -Namespace ThomyKay.Confluence -Class ConfluenceProxy) -------------------------------------------------------------------------------- /Administration/Clear-CflTrash.ps1: -------------------------------------------------------------------------------- 1 | function Clear-CflTrash 2 | { 3 | <# 4 | .SYNOPSIS 5 | Clears the confluence trash for 1 or multiple spaces. 6 | 7 | .DESCRIPTION 8 | A detailed description of the function. 9 | 10 | .PARAMETER ParameterA 11 | The description of the ParameterA parameter. 12 | 13 | .PARAMETER ParameterB 14 | The description of the ParameterB parameter. 15 | 16 | .EXAMPLE 17 | PS C:\> Get-Something -ParameterA 'One value' -ParameterB 32 18 | 19 | .EXAMPLE 20 | PS C:\> Get-Something 'One value' 32 21 | 22 | .INPUTS 23 | System.String,System.Int32 24 | 25 | .NOTES 26 | Additional information about the function go here. 27 | 28 | .LINK 29 | about_functions_advanced 30 | 31 | .LINK 32 | about_comment_based_help 33 | 34 | #> 35 | 36 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 37 | param ( 38 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ParameterSetName = "BySpace")] 39 | [ValidateNotNull()] 40 | [ThomyKay.Confluence.RemoteSpaceSummary[]] $Space, 41 | 42 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ParameterSetName = "BySpaceKey")] 43 | [ValidateNotNull()] 44 | [string[]] $SpaceKey, 45 | 46 | [Parameter(Mandatory = $false)] 47 | [ValidateNotNull()] 48 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 49 | ) 50 | process 51 | { 52 | switch ($psCmdlet.ParameterSetName) 53 | { 54 | "BySpace" { $Space | %{[array]$SpaceKey += $_.Key}} 55 | } 56 | 57 | if ($psCmdlet.ShouldProcess("space '$SpaceKey'")) 58 | { 59 | $SpaceKey | %{[Void]$session.Proxy.emptyTrash($session.Token, $_)} 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Administration/Disable-CflAnonymousAccess.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 5:55:43 PM 3 | #Script: Disable-CflAnonymousAccess 4 | function Disable-CflAnonymousAccess 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | 13 | if ($psCmdlet.ShouldProcess($session.Proxy.Url)) 14 | { 15 | $Session.Proxy.setEnableAnonymousAccess($session.Token, $false) 16 | } 17 | } -------------------------------------------------------------------------------- /Administration/Disable-CflWysiwyg.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 5:57:58 PM 3 | #Script: Disable-CflWysiwyg 4 | function Disable-CflWysiwyg 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | 13 | if ($psCmdlet.ShouldProcess($session.Proxy.Url)) 14 | { 15 | $Session.Proxy.setEnableWysiwyg($session.Token, $false) 16 | } 17 | } -------------------------------------------------------------------------------- /Administration/Enable-CflAnonymousAccess.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 5:51:27 PM 3 | #Script: Enable-CflAnonymousAccess 4 | function Enable-CflAnonymousAccess 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | 13 | if ($psCmdlet.ShouldProcess($session.Proxy.Url)) 14 | { 15 | $Session.Proxy.setEnableAnonymousAccess($session.Token, $true) 16 | } 17 | } -------------------------------------------------------------------------------- /Administration/Enable-CflWysiwyg.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 5:57:28 PM 3 | #Script: Enable-CflWysiwyg 4 | function Enable-CflWysiwyg 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | 13 | if ($psCmdlet.ShouldProcess($session.Proxy.Url)) 14 | { 15 | $Session.Proxy.setEnableWysiwyg($session.Token, $true) 16 | } 17 | } -------------------------------------------------------------------------------- /Administration/Get-CflTrashItem.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflTrashItem 2 | { 3 | <# 4 | .SYNOPSIS 5 | Lists the content of the Confluence trash. 6 | 7 | .DESCRIPTION 8 | A detailed description of the function. 9 | 10 | .PARAMETER ParameterA 11 | The description of the ParameterA parameter. 12 | 13 | .PARAMETER ParameterB 14 | The description of the ParameterB parameter. 15 | 16 | .EXAMPLE 17 | PS C:\> Get-Something -ParameterA 'One value' -ParameterB 32 18 | 19 | .EXAMPLE 20 | PS C:\> Get-Something 'One value' 32 21 | 22 | .INPUTS 23 | System.String,System.Int32 24 | 25 | .OUTPUTS 26 | System.String 27 | 28 | .NOTES 29 | Additional information about the function go here. 30 | 31 | .LINK 32 | about_functions_advanced 33 | 34 | .LINK 35 | about_comment_based_help 36 | 37 | #> 38 | 39 | [CmdletBinding(DefaultParameterSetName = "BySpaceKey")] 40 | param ( 41 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 42 | [string]$Title = "*", 43 | 44 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, ParameterSetName = "BySpace")] 45 | [ThomyKay.Confluence.RemoteSpaceSummary[]] $Space = (Get-CflSpace), 46 | 47 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, ParameterSetName = "BySpaceKey")] 48 | [string[]] $SpaceKey = (Get-CflSpace | %{$_.Key}), 49 | 50 | [Parameter(Mandatory = $false)] 51 | [ValidateNotNull()] 52 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 53 | ) 54 | 55 | process 56 | { 57 | switch ($psCmdlet.ParameterSetName) 58 | { 59 | "BySpace" { $Space | %{[array]$SpaceKey += $_.Key}} 60 | } 61 | 62 | $SpaceKey | %{($session.Proxy.getTrashContents($session.Token, $_, 0, [int]::MaxValue)).content | Where-Object {$_.Title -like $Title}} 63 | } 64 | } -------------------------------------------------------------------------------- /Administration/Remove-CflTrashItem.ps1: -------------------------------------------------------------------------------- 1 | function Remove-CflTrashItem 2 | { 3 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 4 | param ( 5 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 6 | [ThomyKay.Confluence.RemoteContentSummary]$TrashItem, 7 | 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | process 13 | { 14 | if ($psCmdlet.ShouldProcess($trashitem.title) 15 | { 16 | [Void]$Session.Proxy.purgeFromTrash($session.Token, $trashitem.space, $trashitem.id) 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Administration/Restore-CflTrashItem.ps1: -------------------------------------------------------------------------------- 1 | function Restore-CflTrashItem 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 6 | [ThomyKay.Confluence.RemoteContentSummary]$TrashItem, 7 | 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | process 13 | { 14 | #[Void]$Session.Proxy.purgeFromTrash($session.Token, $trashitem.space, $trashitem.id) 15 | Write-Warning "Restore is currently missing in the Confluence web service." 16 | } 17 | } -------------------------------------------------------------------------------- /CflSession.cs: -------------------------------------------------------------------------------- 1 | namespace ThomyKay.Confluence 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | /// 8 | /// Holds the information about a single session. 9 | /// 10 | public class CflSession 11 | { 12 | private string token; 13 | 14 | private object proxy; 15 | 16 | private string connectionUri; 17 | 18 | /// 19 | /// Gets or sets the proxy. 20 | /// 21 | /// The proxy. 22 | public object Proxy 23 | { 24 | get 25 | { 26 | return proxy; 27 | } 28 | set 29 | { 30 | proxy = value; 31 | } 32 | } 33 | 34 | public string Token 35 | { 36 | get 37 | { 38 | return token; 39 | } 40 | set 41 | { 42 | token = value; 43 | } 44 | } 45 | public string ConnectionUri 46 | { 47 | get 48 | { 49 | return connectionUri; 50 | } 51 | set 52 | { 53 | connectionUri = value; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CflSessionManager.cs: -------------------------------------------------------------------------------- 1 | namespace ThomyKay.Confluence 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | /// 8 | /// Holds a list of sessions. 9 | /// 10 | public class CflSessionManager 11 | { 12 | private List sessions = new List(); 13 | private CflSession currentSession; 14 | 15 | /// 16 | /// Gets or sets the sessions. 17 | /// 18 | /// The sessions. 19 | public List Sessions 20 | { 21 | get { return sessions; } 22 | } 23 | 24 | /// 25 | /// Gets or sets the current session. 26 | /// 27 | /// The current session. 28 | public CflSession CurrentSession 29 | { 30 | get 31 | { 32 | return currentSession; 33 | } 34 | set 35 | { 36 | currentSession = value; 37 | } 38 | } 39 | 40 | public CflSession Enter(CflSession session) 41 | { 42 | if (!this.Sessions.Contains(session)) 43 | { 44 | this.Sessions.Add(session); 45 | } 46 | 47 | this.CurrentSession = session; 48 | 49 | return session; 50 | } 51 | 52 | public void Remove(CflSession session) 53 | { 54 | if (this.Sessions.Contains(session)) 55 | { 56 | this.Sessions.Remove(session); 57 | } 58 | 59 | if (this.CurrentSession == session) 60 | { 61 | this.CurrentSession = null; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Confluence.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {1A30125B-FB0F-4FBE-863A-7118797CCF6F} 9 | Library 10 | Properties 11 | Confluence 12 | Confluence 13 | v3.5 14 | 15 | 16 | 512 17 | publish\ 18 | true 19 | Disk 20 | false 21 | Foreground 22 | 7 23 | Days 24 | false 25 | false 26 | true 27 | 0 28 | 1.0.0.%2a 29 | false 30 | false 31 | true 32 | 33 | 34 | x86 35 | true 36 | full 37 | false 38 | bin\Debug\ 39 | DEBUG;TRACE 40 | prompt 41 | 4 42 | 43 | 44 | x86 45 | pdbonly 46 | true 47 | bin\Release\ 48 | TRACE 49 | prompt 50 | 4 51 | 52 | 53 | 54 | 55 | 56 | 57 | PreserveNewest 58 | Designer 59 | 60 | 61 | PreserveNewest 62 | 63 | 64 | PreserveNewest 65 | 66 | 67 | PreserveNewest 68 | 69 | 70 | PreserveNewest 71 | 72 | 73 | PreserveNewest 74 | 75 | 76 | PreserveNewest 77 | 78 | 79 | PreserveNewest 80 | 81 | 82 | PreserveNewest 83 | 84 | 85 | 86 | 87 | PreserveNewest 88 | 89 | 90 | PreserveNewest 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | PreserveNewest 99 | 100 | 101 | 102 | 103 | PreserveNewest 104 | 105 | 106 | PreserveNewest 107 | 108 | 109 | 110 | 111 | PreserveNewest 112 | 113 | 114 | PreserveNewest 115 | 116 | 117 | PreserveNewest 118 | 119 | 120 | PreserveNewest 121 | 122 | 123 | PreserveNewest 124 | 125 | 126 | 127 | 128 | PreserveNewest 129 | 130 | 131 | PreserveNewest 132 | 133 | 134 | 135 | 136 | PreserveNewest 137 | 138 | 139 | PreserveNewest 140 | 141 | 142 | PreserveNewest 143 | 144 | 145 | 146 | 147 | PreserveNewest 148 | 149 | 150 | PreserveNewest 151 | 152 | 153 | PreserveNewest 154 | 155 | 156 | PreserveNewest 157 | 158 | 159 | PreserveNewest 160 | 161 | 162 | PreserveNewest 163 | 164 | 165 | PreserveNewest 166 | 167 | 168 | 169 | 170 | False 171 | .NET Framework 3.5 SP1 Client Profile 172 | false 173 | 174 | 175 | False 176 | .NET Framework 3.5 SP1 177 | true 178 | 179 | 180 | False 181 | Windows Installer 3.1 182 | true 183 | 184 | 185 | 186 | 187 | PreserveNewest 188 | 189 | 190 | PreserveNewest 191 | 192 | 193 | PreserveNewest 194 | 195 | 196 | PreserveNewest 197 | 198 | 199 | PreserveNewest 200 | 201 | 202 | PreserveNewest 203 | 204 | 205 | PreserveNewest 206 | 207 | 208 | PreserveNewest 209 | Designer 210 | 211 | 212 | PreserveNewest 213 | Designer 214 | 215 | 216 | PreserveNewest 217 | 218 | 219 | 220 | 221 | PreserveNewest 222 | 223 | 224 | PreserveNewest 225 | 226 | 227 | PreserveNewest 228 | 229 | 230 | PreserveNewest 231 | 232 | 233 | 234 | 235 | PreserveNewest 236 | 237 | 238 | PreserveNewest 239 | 240 | 241 | 242 | 243 | PreserveNewest 244 | 245 | 246 | PreserveNewest 247 | 248 | 249 | 250 | 251 | PreserveNewest 252 | 253 | 254 | PreserveNewest 255 | 256 | 257 | 258 | 259 | PreserveNewest 260 | 261 | 262 | PreserveNewest 263 | 264 | 265 | PreserveNewest 266 | 267 | 268 | PreserveNewest 269 | 270 | 271 | PreserveNewest 272 | 273 | 274 | PreserveNewest 275 | 276 | 277 | PreserveNewest 278 | 279 | 280 | 281 | PreserveNewest 282 | 283 | 284 | PreserveNewest 285 | 286 | 287 | PreserveNewest 288 | 289 | 290 | 291 | PreserveNewest 292 | 293 | 294 | PreserveNewest 295 | 296 | 297 | PreserveNewest 298 | 299 | 300 | PreserveNewest 301 | 302 | 303 | PreserveNewest 304 | 305 | 306 | PreserveNewest 307 | 308 | 309 | PreserveNewest 310 | 311 | 312 | PreserveNewest 313 | 314 | 315 | PreserveNewest 316 | 317 | 318 | 319 | PreserveNewest 320 | 321 | 322 | 323 | 324 | PreserveNewest 325 | 326 | 327 | 328 | 329 | 330 | 331 | 338 | -------------------------------------------------------------------------------- /Confluence.gpState: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Content/Add-CflAttachment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 7:02:00 PM 3 | #Script: Add-CflAttachment 4 | function Add-CflAttachment 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 9 | [ValidateScript({$_ -is [ThomyKay.Confluence.RemoteBlogEntrySummary] -or $_ -is [ThomyKay.Confluence.RemotePageSummary]})] 10 | $Item, 11 | 12 | [string]$Name, 13 | 14 | [string]$Path, 15 | 16 | [string]$ContentType, 17 | 18 | [Parameter(Mandatory = $false)] 19 | [ValidateNotNull()] 20 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 21 | ) 22 | begin { 23 | } 24 | process { 25 | if (!$ContentType) 26 | { 27 | $ContentType = "application/pdf" 28 | } 29 | 30 | $attachment = New-Object ThomyKay.Confluence.RemoteAttachment -Property @{ 31 | PageId = $Item.Id; 32 | Title = $Name; 33 | Comment = $Comment; 34 | FileName = $Name; 35 | ContentType = $ContentType; 36 | } 37 | 38 | $content = Get-Content $Path -Encoding Byte 39 | $session.Proxy.addAttachment($session.Token, $Item.id, $attachment, $content) 40 | } 41 | end { 42 | } 43 | } -------------------------------------------------------------------------------- /Content/Add-CflComment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 6:29:01 PM 3 | #Script: Add-CflComment 4 | function Add-CflComment 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 9 | [ValidateScript({$_ -is [ThomyKay.Confluence.RemoteBlogEntrySummary] -or $_ -is [ThomyKay.Confluence.RemotePageSummary]})] 10 | $Item, 11 | 12 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 13 | [string]$Content, 14 | 15 | [Parameter(Mandatory = $false)] 16 | [ValidateNotNull()] 17 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 18 | ) 19 | 20 | $comment = New-Object ThomyKay.Confluence.RemoteComment -Property @{ 21 | PageId = $Item.id; 22 | Content = $Content; 23 | } 24 | 25 | $session.Proxy.addComment($Session.Token, $comment) 26 | } -------------------------------------------------------------------------------- /Content/Add-CflLabel.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 2/1/2012 15:24:51 3 | #Script: Add-CflLabel 4 | function Add-CflLabel 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 9 | [ValidateScript({$_ -is [ThomyKay.Confluence.RemoteBlogEntrySummary] -or $_ -is [ThomyKay.Confluence.RemotePageSummary]})] 10 | $Item, 11 | 12 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 13 | [string[]]$Name, 14 | 15 | [Parameter(Mandatory = $false)] 16 | [ValidateNotNull()] 17 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 18 | ) 19 | begin {} 20 | process 21 | { 22 | $Name | %{ 23 | $label = ($_.Trim()) -replace " & ","_" ` 24 | -replace "&","_" ` 25 | -replace " / ","_"` 26 | -replace "/","_"` 27 | -replace " \\ ", "_"` 28 | -replace "\\","_"` 29 | -replace " ","_" 30 | 31 | [void]$session.Proxy.addLabelByName($session.Token, $label, $Item.id); 32 | } 33 | } 34 | end {} 35 | } -------------------------------------------------------------------------------- /Content/Get-CflAttachment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 6:48:49 PM 3 | #Script: Get-CflAttachment 4 | function Get-CflAttachment 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ValidateScript({$_ -is [ThomyKay.Confluence.RemoteBlogEntrySummary] -or $_ -is [ThomyKay.Confluence.RemotePageSummary]})] 10 | $Item, 11 | 12 | [Parameter(Mandatory = $false)] 13 | [string]$FileName = "*", 14 | 15 | [Parameter(Mandatory = $false)] 16 | [string]$Comment = "*", 17 | 18 | [Parameter(Mandatory = $false)] 19 | [ValidateNotNull()] 20 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 21 | ) 22 | 23 | process 24 | { 25 | $Session.Proxy.getAttachments($Session.Token, $Item.Id) | Where-Object {$_.FileName -like $FileName -and $_.Comment -like $Comment} 26 | } 27 | } -------------------------------------------------------------------------------- /Content/Get-CflBlogEntry.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:12:01 PM 3 | #Script: Get-CflBlogEntry 4 | function Get-CflBlogEntry 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Title = "*", 10 | 11 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true)] 12 | [ThomyKay.Confluence.RemoteSpaceSummary[]] $Space = (Get-CflSpace), 13 | 14 | [Parameter(Mandatory = $false)] 15 | [ValidateNotNull()] 16 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 17 | ) 18 | 19 | ($Space | %{$session.Proxy.getBlogEntries($session.Token, $_.key)}) | Where-Object {$_.title -like $Title} 20 | } -------------------------------------------------------------------------------- /Content/Get-CflBookmark.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 2/1/2012 15:57:53 3 | #Script: Get-CflBookmark 4 | function GetCflBookmark 5 | { 6 | param ( 7 | 8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /Content/Get-CflComment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 6:29:20 PM 3 | #Script: Get-CflComment 4 | function Get-CflComment 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | 9 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 10 | [ValidateScript({$_ -is [ThomyKay.Confluence.RemoteBlogEntrySummary] -or $_ -is [ThomyKay.Confluence.RemotePageSummary]})] 11 | $Item, 12 | 13 | [Parameter(Mandatory = $false, Position = 1)] 14 | [string]$Content = "*", 15 | 16 | [Parameter(Mandatory = $false)] 17 | [ValidateNotNull()] 18 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 19 | ) 20 | process 21 | { 22 | $Session.Proxy.getComments($Session.Token, $Item.Id) | Where-Object {$_.Content -like $Content} 23 | } 24 | } -------------------------------------------------------------------------------- /Content/Get-CflLabel.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/28/2011 9:25:40 PM 3 | #Script: Script1 4 | function Get-CflLabel 5 | { 6 | [CmdletBinding(DefaultParameterSetName = "Popular")] 7 | param ( 8 | 9 | [Parameter(Mandatory = $false, Position = 0)] 10 | [string]$Name = "*", 11 | 12 | [Parameter(Mandatory = $false, ParameterSetName = "Popular")] 13 | [switch]$Popular, 14 | 15 | [Parameter(Mandatory = $false)] 16 | [ThomyKay.Confluence.RemoteSpaceSummary[]] $Space = (Get-CflSpace), 17 | 18 | 19 | [Parameter(Mandatory = $true, ParameterSetName = "Recent")] 20 | [switch]$Recent, 21 | 22 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = "Item", ValueFromPipeline=$true)] 23 | $Item, 24 | 25 | [Parameter(Mandatory = $false)] 26 | [ValidateNotNull()] 27 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 28 | ) 29 | begin { 30 | } 31 | process { 32 | switch ($psCmdlet.ParameterSetName) 33 | { 34 | "Popular" { 35 | if (!$PSBoundParameters.ContainsKey("Space")) 36 | { 37 | $Session.Proxy.getMostPopularLabels($session.Token, 100) | Where-Object {$_.name -like $Name} 38 | } 39 | else 40 | { 41 | $Space | %{$session.Proxy.getMostPopularLabelsInSpace($session.Token, $_.key, 100)} | Where-Object {$_.name -like $Name} 42 | } 43 | } 44 | "Recent" { 45 | if (!$PSBoundParameters.ContainsKey("Space")) 46 | { 47 | $session.Proxy.getRecentlyUsedLabels($session.Token, 100) | Where-Object {$_.name -like $Name} 48 | } 49 | else 50 | { 51 | $Space | %{$session.Proxy.getRecentlyUsedLabelsInSpace($session.Token, $_.key, 100)} | Where-Object {$_.name -like $Name} 52 | } 53 | } 54 | "Item" { 55 | #$session.P 56 | $session.Proxy.getLabelsById($session.Token, $Item.id) | Where-Object {$_.name -like $Name} 57 | } 58 | } 59 | } 60 | end { 61 | } 62 | } -------------------------------------------------------------------------------- /Content/Get-CflPage.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:12:35 PM 3 | #Script: Get-CflPage 4 | function Get-CflPage 5 | { 6 | [CmdletBinding(DefaultParameterSetName = "BySpace")] 7 | param ( 8 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Title = "*", 10 | 11 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, ParameterSetName = "BySpace")] 12 | [ThomyKay.Confluence.RemoteSpaceSummary[]]$Space = (Get-CflSpace), 13 | 14 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = "ChildrenOf")] 15 | [ThomyKay.Confluence.RemotePageSummary]$ChildrenOf, 16 | 17 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = "AncestorsOf")] 18 | [ThomyKay.Confluence.RemotePageSummary]$AncestorsOf, 19 | 20 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = "DescendentsOf")] 21 | [ThomyKay.Confluence.RemotePageSummary]$DescendentsOf, 22 | 23 | [Parameter(Mandatory = $false)] 24 | [ValidateNotNull()] 25 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 26 | ) 27 | begin{} 28 | process 29 | { 30 | switch ($psCmdlet.ParameterSetName) 31 | { 32 | "BySpace" 33 | { 34 | $Space | %{[array]$SpaceKey += $_.Key} 35 | ($SpaceKey | %{$session.Proxy.getPages($session.Token, $_)}) | Where-Object {$_.title -like $Title} 36 | } 37 | "ChildrenOf" 38 | { 39 | $session.Proxy.getChildren($session.Token,$ChildrenOf.id) | Where-Object {$_.title -like $Title} 40 | } 41 | "AncestorsOf" 42 | { 43 | $session.Proxy.getAncestors($session.Token,$AncestorsOf.id) | Where-Object {$_.title -like $Title} 44 | } 45 | "DescendentsOf" 46 | { 47 | $session.Proxy.getDescendents($session.Token,$DescendentsOf.id) | Where-Object {$_.title -like $Title} 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Content/Move-CflPage.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/15/2011 4:28:37 PM 3 | #Script: Move-CflPage 4 | function Move-CflPage 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemotePageSummary]$Page, 10 | 11 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 12 | [Alias("ToPage")] 13 | [ThomyKay.Confluence.RemotePageSummary]$TargetPage, 14 | 15 | [Parameter(Mandatory = $false)] 16 | [ValidateNotNull()] 17 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 18 | ) 19 | begin { 20 | } 21 | process { 22 | if ($PSCmdlet.ShouldProcess($Page.title)) 23 | { 24 | $Session.Proxy.movePage($Session.Token, $Page.id, $TargetPage.id, "append") | out-null 25 | } 26 | } 27 | end { 28 | } 29 | } -------------------------------------------------------------------------------- /Content/New-CflBlogEntry.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 8:38:40 PM 3 | #Script: New-CflBlogEntry 4 | function New-CflBlogEntry 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Title, 10 | 11 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 12 | [string[]]$Content, 13 | 14 | [Parameter(Mandatory = $true, Position = 2, ValueFromPipeline = $true)] 15 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 16 | 17 | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] 18 | [datetime]$PublishDate, 19 | 20 | [Parameter(Mandatory = $false)] 21 | [ValidateNotNull()] 22 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 23 | ) 24 | process 25 | { 26 | if ($psCmdlet.ShouldProcess($Title)) 27 | { 28 | $blogEntry = New-Object ThomyKay.Confluence.RemoteBlogEntry -Property @{ 29 | Title = $Title; 30 | Content = $Content | Out-String | ConvertTo-CflStorageFormat -Session $Session; 31 | Space = $Space.key; 32 | PublishDate = $PublishDate 33 | } 34 | 35 | $session.Proxy.storeBlogEntry($session.Token, $blogEntry) 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Content/New-CflBookmark.ps1: -------------------------------------------------------------------------------- 1 | function New-CflBookmark 2 | { 3 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")] 4 | param ( 5 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true)] 6 | [Alias("Name")] 7 | [string]$Title = $Url, 8 | 9 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true)] 10 | [Alias("Uri", "Address")] 11 | [Uri]$Url, 12 | 13 | [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 14 | [string[]]$Description, 15 | 16 | [Parameter(Mandatory = $true, Position = 2)] 17 | #[ValidateScript({$space -is [ThomyKay.Confluence.RemoteSpaceSummary] -or $space -is [string]})] 18 | $Space, 19 | 20 | [Parameter(Mandatory = $false)] 21 | [string[]]$Label, 22 | 23 | [Parameter(Mandatory = $false)] 24 | [switch]$Force, 25 | 26 | [Parameter(Mandatory = $false)] 27 | [ValidateNotNull()] 28 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 29 | ) 30 | process { 31 | $bookmarksPage = Get-CflPage -Title ".bookmarks" -Space $space -Session $Session 32 | if (!$bookmarksPage -and $Force) 33 | { 34 | $bookmarksPage = New-CflPage -Title ".bookmarks" -Space $Space -Session $Session 35 | } 36 | 37 | $content = "{bookmark:url=$Url|htmlbody=$true}$Description{bookmark}" 38 | New-CflPage -Title $Title -Content (ConvertTo-CflStorageFormat $content -Session $Session) -Space $Space -ParentPage $bookmarksPage -Session $Session 39 | } 40 | } -------------------------------------------------------------------------------- /Content/New-CflPage.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/3/2011 1:21:12 PM 3 | #Script: New-CflPage 4 | function New-CflPage 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Title, 10 | 11 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 12 | [string[]]$Content, 13 | 14 | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] 15 | $ParentPage, 16 | 17 | [Parameter(Mandatory = $true, Position = 2)] 18 | #[ValidateScript({$space -is [ThomyKay.Confluence.RemoteSpaceSummary] -or $space -is [string]})] 19 | $Space, 20 | 21 | [Parameter(Mandatory = $false)] 22 | [ValidateNotNull()] 23 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 24 | ) 25 | 26 | process 27 | { 28 | if ($psCmdlet.ShouldProcess($Title)) 29 | { 30 | if ($Space -is [ThomyKay.Confluence.RemoteSpaceSummary]) 31 | { 32 | $space = $space.Key 33 | } 34 | 35 | if ($ParentPage) 36 | { 37 | $parentId = $ParentPage.Id 38 | } 39 | 40 | $page = new-object ThomyKay.Confluence.RemotePage -Property @{ 41 | Title = $Title; 42 | Content = $Content; 43 | Space = $Space; 44 | ParentId = $parentId 45 | } 46 | 47 | $Session.Proxy.storePage($Session.Token, $page) 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Content/Remove-CflAttachment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 9:25:21 PM 3 | #Script: Remove-CflAttachment 4 | function Remove-CflAttachment 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.RemoteAttachment]$Attachment, 11 | 12 | [Parameter(Mandatory = $false)] 13 | [ValidateNotNull()] 14 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 15 | ) 16 | process 17 | { 18 | if ($psCmdlet.ShouldProcess($Attachment.Title)) 19 | { 20 | [Void]$Session.Proxy.removeAttachment($session.Token, $Attachment.PageId, $Attachment.Title) 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Content/Remove-CflComment.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 9:24:15 PM 3 | #Script: Remove-CflComment 4 | function Remove-CflComment 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.RemoteComment]$Comment, 11 | 12 | [Parameter(Mandatory = $false)] 13 | [ValidateNotNull()] 14 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 15 | ) 16 | 17 | process 18 | { 19 | if ($psCmdlet.ShouldProcess($Comment.Title)) 20 | { 21 | [Void]$Session.Proxy.removeComment($Session.Token, $Comment.Id) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Content/Remove-CflLabel.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Script: Remove-CflLabel 3 | function Remove-CflLabel 4 | { 5 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 6 | param ( 7 | [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "ListOfNames")] 8 | [string[]]$Name, 9 | 10 | [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "LabelObject", ValueFromPipeline=$true)] 11 | [ThomyKay.Confluence.RemoteLabel]$Label, 12 | 13 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline=$true)] 14 | [ThomyKay.Confluence.RemotePageSummary]$Item, 15 | 16 | 17 | 18 | [Parameter(Mandatory = $false)] 19 | [ValidateNotNull()] 20 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 21 | ) 22 | 23 | process 24 | { 25 | switch ($psCmdlet.ParameterSetName) 26 | { 27 | "ListOfNames" { 28 | if ($psCmdlet.ShouldProcess("Remove label from '{0}'." -f $item.title)) 29 | { 30 | $Name | %{ 31 | [void]$Session.Proxy.removeLabelByName($Session.Token,$_, $item.id) 32 | } 33 | } 34 | } 35 | "LabelObject" { 36 | if ($psCmdlet.ShouldProcess(("label '{0}', item '{1}'." -f $Label.name, $item.title))) 37 | { 38 | [void]$Session.Proxy.removeLabelByObject($Session.Token,$Label, $item.id) 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Content/Remove-CflPage.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/3/2011 1:22:24 PM 3 | #Script: Remove-CflPage 4 | function Remove-CflPage 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemotePageSummary]$Page, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | begin {} 16 | process { 17 | if ($psCmdlet.ShouldProcess($Page.Title)) 18 | { 19 | [Void]$Session.Proxy.removePage($Session.Token, $Page.id) 20 | } 21 | } 22 | end {} 23 | } -------------------------------------------------------------------------------- /Content/Set-CflPage.ps1: -------------------------------------------------------------------------------- 1 | function Set-CflPage 2 | { 3 | <# 4 | .SYNOPSIS 5 | Sets the content of a page. 6 | 7 | .DESCRIPTION 8 | If the page doesn't exist, it gets created. if the page exists already, a new version is created. 9 | 10 | .EXAMPLE 11 | PS C:\> Get-Something -ParameterA 'One value' -ParameterB 32 12 | 13 | .EXAMPLE 14 | PS C:\> Get-Something 'One value' 32 15 | 16 | .INPUTS 17 | System.String,System.Int32 18 | 19 | .OUTPUTS 20 | System.String 21 | 22 | .NOTES 23 | Additional information about the function go here. 24 | 25 | #> 26 | 27 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")] 28 | param ( 29 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipelineByPropertyName = $true)] 30 | [string]$Title, 31 | 32 | [Parameter(Mandatory = $false, Position = 2, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 33 | [string[]]$Content, 34 | 35 | [Parameter(Mandatory = $false)] 36 | [switch]$MinorEdit, 37 | 38 | [Parameter(Mandatory = $false)] 39 | [string]$VersionComment, 40 | 41 | [Parameter(Mandatory = $true, Position = 2)] 42 | $Space, 43 | 44 | [Parameter(Mandatory = $false)] 45 | [ValidateNotNull()] 46 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 47 | ) 48 | 49 | if ($psCmdlet.ShouldProcess($Title)) 50 | { 51 | if ($Space -is [ThomyKay.Confluence.RemoteSpaceSummary]) 52 | { 53 | $space = $space.Key 54 | } 55 | 56 | $page = Get-CflPage $Title $Space | select -First 1 57 | 58 | if (!$page) 59 | { 60 | Write-Verbose "Page $Title not found, creating a new page." 61 | [Void]$PSBoundParameters.Remove("MinorEdit") 62 | [Void]$PSBoundParameters.Remove("VersionComment") 63 | New-CflPage @psBoundParameters 64 | } 65 | else 66 | { 67 | Write-Verbose "Page $Title found, updating page." 68 | [Void]$PSBoundParameters.Remove("Space") 69 | $PSBoundParameters.Add("Page", $page) 70 | Update-CflPage @psBoundParameters 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Content/Update-CflBlogEntry.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/9/2011 5:35:09 PM 3 | #Script: Update-CflBlogEntry 4 | function Update-CflBlogEntry 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | ) 9 | 10 | 11 | } -------------------------------------------------------------------------------- /Content/Update-CflPage.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/3/2011 4:28:37 PM 3 | #Script: Update-CflPage 4 | function Update-CflPage 5 | { 6 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemotePageSummary]$Page, 10 | 11 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipelineByPropertyName = $true)] 12 | [string]$Title, 13 | 14 | [Parameter(Mandatory = $false, Position = 2, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 15 | [string[]]$Content, 16 | 17 | [Parameter(Mandatory = $false)] 18 | [switch]$MinorEdit, 19 | 20 | [Parameter(Mandatory = $false)] 21 | [string]$VersionComment, 22 | 23 | [Parameter(Mandatory = $false)] 24 | [ValidateNotNull()] 25 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 26 | ) 27 | 28 | 29 | $realPage = $Session.Proxy.getPage($Session.Token, $Page.space, $page.title) 30 | 31 | if ($psBoundParameters.ContainsKey("Title")) {$realPage.Title = $Title} 32 | if ($psBoundParameters.ContainsKey("Content")) 33 | { 34 | $realPage.Content = $Content 35 | } 36 | 37 | $changes = New-Object ThomyKay.Confluence.RemotePageUpdateOptions -Property @{ 38 | MinorEdit = $MinorEdit.IsPresent; 39 | VersionComment = $VersionComment 40 | } 41 | 42 | if ($PSCmdlet.ShouldProcess($page.title)) 43 | { 44 | $Session.Proxy.updatePage($Session.Token, $realPage, $changes) 45 | } 46 | } -------------------------------------------------------------------------------- /Enter-CflSession.ps1: -------------------------------------------------------------------------------- 1 | function Enter-CflSession 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [Parameter(Mandatory=$true, Position = 0)] 6 | [Uri]$ConnectionUri, 7 | 8 | [Parameter(Mandatory=$true, Position = 1)] 9 | [Management.Automation.Credential()] 10 | [Management.Automation.PSCredential]$Credential 11 | ) 12 | 13 | [Uri]$soapUri = $ConnectionUri.AbsoluteUri.TrimEnd('/') + "/rpc/soap-axis/confluenceservice-v2?wsdl" 14 | #$proxy = New-WebServiceProxy -Uri $soapUri -Credential $Credential -Namespace Throw.ThomyKay.Confluence -Class ConfluenceProxy 15 | 16 | #TODO: Care about domain part? 17 | $proxy.Url = $soapUri 18 | $proxy.Credentials = $Credential 19 | $token = $proxy.login($Credential.GetNetworkCredential().UserName, $Credential.GetNetworkCredential().Password) 20 | 21 | $session = New-Object ThomyKay.Confluence.CflSession -property @{ 22 | Token = $token; 23 | Proxy = $proxy; 24 | ConnectionUri = $ConnectionUri.AbsoluteUri.TrimEnd('/') 25 | } 26 | 27 | $CflSessionManager.Enter($session) 28 | } -------------------------------------------------------------------------------- /Exit-CflSession.ps1: -------------------------------------------------------------------------------- 1 | function Exit-CflSession 2 | { 3 | [CmdletBinding()] 4 | param( 5 | ) 6 | } -------------------------------------------------------------------------------- /Formatting/ConvertTo-CflChart.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Renders the input as a Confluence chart. 4 | 5 | .DESCRIPTION 6 | A detailed description of the function. 7 | 8 | .PARAMETER ParameterA 9 | The description of the ParameterA parameter. 10 | 11 | .PARAMETER ParameterB 12 | The description of the ParameterB parameter. 13 | 14 | .EXAMPLE 15 | PS C:\> Get-Something -ParameterA 'One value' -ParameterB 32 16 | 17 | .EXAMPLE 18 | PS C:\> Get-Something 'One value' 32 19 | 20 | .INPUTS 21 | System.String,System.Int32 22 | 23 | .OUTPUTS 24 | System.String 25 | 26 | .NOTES 27 | Additional information about the function go here. 28 | 29 | .LINK 30 | about_functions_advanced 31 | 32 | .LINK 33 | http://confluence.atlassian.com/display/CONF34/Chart+Macro 34 | 35 | #> 36 | 37 | function ConvertTo-CflChart 38 | { 39 | [CmdletBinding()] 40 | param ( 41 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 42 | $InputObject, 43 | 44 | #charttype parameters 45 | [ValidateSet("Pie", "Bar", "Line", "Area", "xyArea", "xyBar", "xyLine", "xyStep", "xyStepArea", "Scatter", "TimeSeries")] 46 | $ChartType = "Pie", 47 | 48 | [Parameter()] 49 | [ValidateSet("vertical", "horizontal")] 50 | $DataOrientation = "vertical", 51 | 52 | [Parameter()] 53 | [switch]$3d, 54 | 55 | [Parameter()] 56 | [switch]$Stacked, 57 | 58 | [Parameter()] 59 | [switch]$DontShowShapes, 60 | 61 | [Parameter()] 62 | [ValidateRange(0,100)] 63 | [int]$Opacity, 64 | 65 | #display control parameters 66 | [Parameter(Mandatory = $false)] 67 | [int]$Width = 300, 68 | 69 | [Parameter(Mandatory = $false)] 70 | [int]$Height = 300, 71 | 72 | [Parameter()] 73 | [ValidateSet("true", "after", "before")] 74 | $DataDisplay, 75 | 76 | #Title and Label Customisation Parameters 77 | [Parameter(Mandatory = $false)] 78 | [string]$Title, 79 | 80 | [Parameter(Mandatory = $false)] 81 | [string]$SubTitle, 82 | 83 | [Parameter(Mandatory = $false)] 84 | [string]$xLabel, 85 | 86 | [Parameter(Mandatory = $false)] 87 | [string]$yLabel, 88 | 89 | [Parameter()] 90 | [switch]$Legend 91 | ) 92 | begin { 93 | "{chart:type=$ChartType|title=$Title|3d=$3d|DataOrientation=$DataOrientation|Width=$Width|Height=$Height|$DataDisplay=$DataDisplay|$SubTitle=$SubTitle|xLabel=$xLabel|yLabel=$yLabel}" 94 | $headerGenerated = $false 95 | } 96 | process { 97 | if (!$headerGenerated) 98 | { 99 | $headerGenerated = $true 100 | $InputObject.PSObject.Properties | % -Begin {$header = ""} -Process {$header += "||$($_.Name)"} -End {$header += "||"} 101 | $header 102 | } 103 | 104 | $InputObject.PSObject.Properties | % -Begin {$row = ""} -Process {$row += "|$($_.Value)"} -End {$row += "|"} 105 | $row 106 | } 107 | end { 108 | "{chart}" 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /Formatting/ConvertTo-CflList.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-CflList 2 | { 3 | param ( 4 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 5 | $InputObject 6 | ) 7 | 8 | process 9 | { 10 | $InputObject.PSObject.Properties | % {"||$($_.Name)|$($_.Value) ||"} 11 | } 12 | } -------------------------------------------------------------------------------- /Formatting/ConvertTo-CflStorageFormat.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/18/2012 18:31:49 3 | #Script: ConvertTo-CflStorageFormat 4 | function ConvertTo-CflStorageFormat 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline = $true)] 9 | [string]$Content, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | process 16 | { 17 | $Session.Proxy.convertWikiToStorageFormat($Session.Token, $Content) 18 | } 19 | } -------------------------------------------------------------------------------- /Formatting/ConvertTo-CflTable.ps1: -------------------------------------------------------------------------------- 1 | #thkrause 2 | #Date: 7/8/2011 2:45:27 PM 3 | #Script: ConvertTo-CflTable 4 | function ConvertTo-CflTable 5 | { 6 | <# 7 | .SYNOPSIS 8 | Converts an input object into a table in Confluence wiki style. 9 | 10 | .DESCRIPTION 11 | A detailed description of the function. 12 | 13 | .PARAMETER ParameterA 14 | The description of the ParameterA parameter. 15 | 16 | .PARAMETER ParameterB 17 | The description of the ParameterB parameter. 18 | 19 | .EXAMPLE 20 | PS C:\> Get-Something -ParameterA 'One value' -ParameterB 32 21 | 22 | .EXAMPLE 23 | PS C:\> Get-Something 'One value' 32 24 | 25 | .INPUTS 26 | System.String,System.Int32 27 | 28 | .OUTPUTS 29 | System.String 30 | 31 | .NOTES 32 | Additional information about the function go here. 33 | 34 | .LINK 35 | about_functions_advanced 36 | 37 | .LINK 38 | about_comment_based_help 39 | 40 | #> 41 | 42 | [CmdletBinding()] 43 | param ( 44 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 45 | $InputObject 46 | ) 47 | begin 48 | { 49 | $headerGenerated = $false 50 | } 51 | process 52 | { 53 | if (!$headerGenerated) 54 | { 55 | $headerGenerated = $true 56 | $InputObject.PSObject.Properties | % -Begin {$header = ""} -Process {$header += "||$($_.Name)"} -End {$header += "||"} 57 | $header 58 | } 59 | 60 | $InputObject.PSObject.Properties | % -Begin {$row = ""} -Process {$row += "|$($_.Value)"} -End {$row += "|"} 61 | $row 62 | } 63 | end 64 | { 65 | } 66 | } -------------------------------------------------------------------------------- /Formatting/ConvertTo-CflTablePlus.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-CflTablePlus 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | ) 6 | } -------------------------------------------------------------------------------- /Formatting/Merge-CflChart.ps1: -------------------------------------------------------------------------------- 1 | function Merge-CflChart 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [Parameter(Mandatory=$true)] 6 | $InputObject, 7 | 8 | [Parameter(Mandatory=$true)] 9 | [string[]]$content 10 | ) 11 | } -------------------------------------------------------------------------------- /Formatting/Merge-CflTable.ps1: -------------------------------------------------------------------------------- 1 | function Merge-CflTable 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [String[]]$ExistingTable, 6 | [String[]]$NewTable 7 | ) 8 | 9 | #TODO: check both table headers 10 | #remove the table header of the second table 11 | } -------------------------------------------------------------------------------- /Get-CflSession.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflSession 2 | { 3 | [CmdletBinding()] 4 | param( 5 | [Parameter(Mandatory = $false)] 6 | [switch]$Current 7 | ) 8 | 9 | if ($Current) 10 | { 11 | $CflSessionManager.CurrentSession 12 | } 13 | else 14 | { 15 | $CflSessionManager.Sessions 16 | } 17 | } -------------------------------------------------------------------------------- /Get-CflSpace.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflSpace 2 | { 3 | [CmdletBinding(DefaultParameterSetName="")] 4 | param ( 5 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 6 | [string]$Name = "*", 7 | 8 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName="ByLabel")] 9 | [string]$Label, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | 16 | process 17 | { 18 | if ($PSCmdlet.ParameterSetName -eq "ByLabel") 19 | { 20 | $spaces = $Session.Proxy.getSpacesWithLabel($Session.Token, $Label) ` 21 | | Where-Object {$_.name -like $Name} 22 | $Session.Proxy.GetSpaces($Session.Token) | Where-Object {$_.key -in $spaces.key} 23 | } 24 | else 25 | { 26 | $Session.Proxy.GetSpaces($Session.Token) | Where-Object {$_.name -like $Name} 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /ImportExport/Convert-CflArchiveUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/30/2012 08:38:46 3 | #Script: Convert-CflArchiveUser 4 | function Convert-CflArchiveUser 5 | { 6 | param ( 7 | [Parameter(Mandatory= $true, Position = 0)] 8 | [ValidateNotNull()] 9 | [string]$Path, 10 | 11 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true)] 12 | [ValidateNotNull()] 13 | [Alias("Name")] 14 | [string]$FromUser, 15 | 16 | [Parameter(Mandatory = $true, Position = 2, ValueFromPipelineByPropertyName = $true)] 17 | [Alias("Value")] 18 | [ValidateNotNull()] 19 | [string]$ToUser, 20 | 21 | [Parameter(Mandatory = $false)] 22 | [ValidateNotNull()] 23 | [string]$NewArchiveFileName 24 | ) 25 | begin 26 | { 27 | $fileName = "entities.xml" 28 | $shell = new-object -com shell.application 29 | $zip = $shell.NameSpace($Path) 30 | $tempDir = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid()) 31 | [void](New-Item $tempDir -ItemType Directory) 32 | $destination = $shell.NameSpace($tempDir) 33 | $source = $zip.Items() | Where-Object {$_.Name -eq $fileName} 34 | $destination.CopyHere($source) 35 | $entityXmlSourcePath = (Join-Path $tempDir $fileName) 36 | [xml]$content = Get-Content -Path $entityXmlSourcePath 37 | $navigator = $content.CreateNavigator() 38 | $occurences = $navigator.Select("//property[(@name='owner' or @name='user' or @name='userName' or @name='lastModifierName' or @name='creatorName') and (not(@class))]") ` 39 | | where {!$_.IsEmptyElement} ` 40 | } 41 | process 42 | { 43 | $thisUserOccurences = $occurences | Where {$_.Value -eq $FromUser} 44 | $thisUserOccurences | %{$_.InnerXml = $ToUser} 45 | #TODO: remove the matches from the collection to prevent 'uebersprechen' in the pipeline 46 | } 47 | end 48 | { 49 | #pack into archive 50 | $content.Save($entityXmlSourcePath) 51 | $newContent = $shell.NameSpace($entityXmlSourcePath) 52 | $source.CopyHere($newContent) 53 | } 54 | } -------------------------------------------------------------------------------- /ImportExport/Export-CflSite.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:07:22 PM 3 | #Script: Export-CflSite 4 | function Export-CflSite 5 | { 6 | param ( 7 | [Parameter(Mandatory=$false)] 8 | [switch]$IncludeAttachments = $true, 9 | 10 | [Parameter(Mandatory = $false)] 11 | [ValidateNotNull()] 12 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 13 | ) 14 | begin { 15 | } 16 | process { 17 | $Session.Proxy.exportSite($Session.Token, $IncludeAttachments.IsPresent) 18 | } 19 | end { 20 | } 21 | } -------------------------------------------------------------------------------- /ImportExport/Export-CflSpace.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:08:24 PM 3 | #Script: Export-CflSpace 4 | function Export-CflSpace 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory= $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 10 | 11 | [Parameter(Mandatory= $false, Position = 1, ValueFromPipeline = $false)] 12 | [ValidateSet("TYPE_HTML", "TYPE_XML")] 13 | [string]$ExportType = "TYPE_XML", 14 | 15 | [Parameter(Mandatory=$false, ValueFromPipeline=$false)] 16 | [switch]$ExportAll, 17 | 18 | [Parameter(Mandatory = $false)] 19 | [ValidateNotNull()] 20 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 21 | ) 22 | begin { 23 | Write-Progress -id 1 -Activity "Space Export" -Status "Initialize" 24 | } 25 | process { 26 | Write-Progress -id 1 -Activity "Space Export" -Status "Execute" -CurrentOperation "Exporting ""$($Space.name)"" ($($Space.key))" 27 | $Session.Proxy.exportSpace($Session.Token, $Space.key,$ExportType, $ExportAll.IsPresent) 28 | } 29 | end { 30 | Write-Progress -id 1 -Activity "Space Export" -Status "Finished" -Completed 31 | } 32 | } -------------------------------------------------------------------------------- /ImportExport/Get-CflArchive.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/30/2012 08:35:58 3 | #Script: Get-CflArchive 4 | function Get-CflArchive 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 9 | [ValidateNotNull()] 10 | [string]$Path 11 | ) 12 | 13 | begin 14 | { 15 | } 16 | process 17 | { 18 | $fileName = "exportDescriptor.properties" 19 | $shell = new-object -com shell.application 20 | $zip = $shell.NameSpace($Path) 21 | $tempDir = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid()) 22 | [void](New-Item $tempDir -ItemType Directory) 23 | try 24 | { 25 | $destination = $shell.NameSpace($tempDir) 26 | $source = $zip.Items() | Where-Object {$_.Name -eq $fileName} 27 | $destination.CopyHere($source) 28 | $values = Import-Csv -Delimiter "=" -Header Name,Value -Path (Join-Path $tempDir $fileName) 29 | $values | % -Begin{$hash = @{}} -Process{$hash.Add($_.Name, $_.Value)} 30 | $result = New-Object psobject -Property $hash 31 | $result 32 | } 33 | finally 34 | { 35 | Remove-Item $tempDir -Recurse 36 | } 37 | } 38 | end 39 | { 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /ImportExport/Get-CflArchiveUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/30/2012 15:13:25 3 | #Script: Get-CflArchiveUser 4 | function Get-CflArchiveUser 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)] 9 | [ValidateNotNull()] 10 | [string]$Path 11 | ) 12 | begin 13 | { 14 | } 15 | process 16 | { 17 | $fileName = "entities.xml" 18 | $shell = new-object -com shell.application 19 | $zip = $shell.NameSpace($Path) 20 | $tempDir = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid()) 21 | [void](New-Item $tempDir -ItemType Directory) 22 | try 23 | { 24 | $destination = $shell.NameSpace($tempDir) 25 | $source = $zip.Items() | Where-Object {$_.Name -eq $fileName} 26 | $destination.CopyHere($source) 27 | 28 | [xml]$content = Get-Content -Path (Join-Path $tempDir $fileName) 29 | $navigator = $content.CreateNavigator() 30 | $navigator.Select("//property[(@name='owner' or @name='user' or @name='userName' or @name='lastModifierName' or @name='creatorName') and (not(@class))]") ` 31 | | where {!$_.IsEmptyElement} ` 32 | | select Value -Unique 33 | } 34 | finally 35 | { 36 | Remove-Item $tempDir -Recurse 37 | } 38 | } 39 | end 40 | { 41 | } 42 | } -------------------------------------------------------------------------------- /ImportExport/Import-CflSite.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:06:51 PM 3 | #Script: Import-CflSite 4 | function Import-CflSite 5 | { 6 | param ( 7 | [Parameter(Mandatory = $false)] 8 | [ValidateNotNull()] 9 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 10 | ) 11 | begin { 12 | } 13 | process { 14 | } 15 | end { 16 | } 17 | } -------------------------------------------------------------------------------- /ImportExport/Import-CflSpace.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 9:07:53 PM 3 | #Script: Import-CflSpace 4 | function Import-CflSpace 5 | { 6 | param ( 7 | [Parameter(Mandatory = $true, Position = 0)] 8 | [string]$Path, 9 | 10 | [Parameter(Mandatory = $false)] 11 | [ValidateNotNull()] 12 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 13 | ) 14 | $content = [System.IO.File]::ReadAllBytes($Path) 15 | [Void]$Session.Proxy.importSpace($Session.Token, $content) 16 | } -------------------------------------------------------------------------------- /ImportExport/Test-CflArchive.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/30/2012 08:35:32 3 | #Script: Test-CflArchive 4 | function Test-CflArchive 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0)] 9 | [ValidateNotNull()] 10 | [string]$Path, 11 | 12 | [Parameter(Mandatory = $true, Position = 1)] 13 | [ValidateSet("space", "all")] 14 | [ValidateNotNull()] 15 | [string]$Type 16 | ) 17 | begin 18 | { 19 | } 20 | process 21 | { 22 | $info = Get-CflArchive $Path 23 | $valid = $info.exportType -ieq $Type 24 | if (!$valid) 25 | { 26 | Write-Verbose "Archive at '$Path' is not a '$Type' archive, it's a '$($info.exportType)' archive." 27 | } 28 | $valid 29 | } 30 | end 31 | { 32 | } 33 | } -------------------------------------------------------------------------------- /Invoke-CflItem.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 4/6/2011 12:33:43 PM 3 | #Script: Invoke-CflItem 4 | function Invoke-CflItem 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ValidateNotNull()] 10 | $Item 11 | ) 12 | 13 | process 14 | { 15 | [Diagnostics.Process]::Start($Item.Url) 16 | } 17 | } -------------------------------------------------------------------------------- /New-CflSession.ps1: -------------------------------------------------------------------------------- 1 | function New-CflSession 2 | { 3 | [CmdletBinding()] 4 | param 5 | ( 6 | ) 7 | } -------------------------------------------------------------------------------- /New-CflSpace.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/22/2011 6:20:00 PM 3 | #Script: New-CflSpace 4 | function New-CflSpace 5 | { 6 | [CmdletBinding()] 7 | param( 8 | [Parameter(Mandatory=$true, Position = 0)] 9 | [Alias("ID")] 10 | [string]$Key, 11 | [Parameter(Mandatory=$true, Position = 1)] 12 | [string]$Name, 13 | [Parameter(Mandatory=$false, Position = 2)] 14 | [string]$Description, 15 | [Parameter(Mandatory = $false)] 16 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 17 | ) 18 | 19 | process { 20 | $space = New-Object ThomyKay.Confluence.RemoteSpace -Property @{ 21 | key = $Key; 22 | name = $Name; 23 | description = $Description 24 | } 25 | $Session.Proxy.addSpace($Session.Token, $space) 26 | } 27 | } -------------------------------------------------------------------------------- /PageSet.cs: -------------------------------------------------------------------------------- 1 | namespace ThomyKay.Confluence 2 | { 3 | using System; 4 | 5 | /// 6 | /// TODO: Update summary. 7 | /// 8 | public enum PageSet 9 | { 10 | Children, 11 | AllChildren, 12 | Parent, 13 | AllParent 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Permissions/Get-CflSpaceLevelPermission.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflSpaceLevelPermission 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [Parameter(Mandatory = $false, Position = 0)] 6 | [ValidateNotNull()] 7 | [string]$Name = "*", 8 | 9 | [Parameter(Mandatory = $false)] 10 | [ValidateNotNull()] 11 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 12 | ) 13 | process { 14 | $Session.Proxy.getSpaceLevelPermissions($Session.Token) ` 15 | | Where {$_ -like $Name}; 16 | } 17 | } -------------------------------------------------------------------------------- /Permissions/Get-CflSpacePermission.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflSpacePermission 2 | { 3 | [CmdletBinding()] 4 | param ( 5 | [Parameter(Mandatory= $true, Position = 0, ValueFromPipeline = $true)] 6 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 7 | 8 | [Parameter(Mandatory= $false)] 9 | [ValidateScript({Get-CflSpaceLevelPermission $_})] 10 | [string]$Type="*", 11 | 12 | [Parameter(Mandatory = $false)] 13 | [ValidateNotNull()] 14 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 15 | ) 16 | process { 17 | $Session.Proxy.getSpacePermissionSets($Session.Token, $Space.key) ` 18 | | Where {$_.type -like $Type} ` 19 | | %{Add-Member -InputObject $_ -Type NoteProperty -Name Space -Value $Space -passthru} 20 | } 21 | } -------------------------------------------------------------------------------- /Plugins/Disable-CflUpmSafeMode.ps1: -------------------------------------------------------------------------------- 1 | function Enable-CflUpmSafeMode { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $false)] 5 | [ValidateNotNull()] 6 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 7 | ) 8 | process { 9 | #https://confluence.atlassian.com/display/STASHKB/How+to+Enable+UPM+Safe+Mode+using+UPM+REST+API 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Plugins/Enable-CflPlugin.ps1: -------------------------------------------------------------------------------- 1 | function Enable-CflPlugin { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $false)] 5 | [ValidateNotNull()] 6 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 7 | ) 8 | process { 9 | } 10 | } -------------------------------------------------------------------------------- /Plugins/Enable-CflUpmSafeMode.ps1: -------------------------------------------------------------------------------- 1 | function Enable-CflUpmSafeMode { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $false)] 5 | [ValidateNotNull()] 6 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 7 | ) 8 | process { 9 | #https://confluence.atlassian.com/display/STASHKB/How+to+Enable+UPM+Safe+Mode+using+UPM+REST+API 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Plugins/Get-CflPlugin.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflPlugin { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $false)] 5 | [ValidateNotNull()] 6 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 7 | ) 8 | process { 9 | $creds = New-Object System.Management.Automation.PSCredential ($Session.Proxy.Credentials.UserName, $Session.Proxy.Credentials.SecurePassword) 10 | $headers = @{Authorization="Basic " + [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${userName}:$password"))} 11 | $result = Invoke-RestMethod -Method Get -Headers $headers -Uri ($Session.ConnectionUri + "/rest/plugins/1.0/") - 12 | $result.plugins | select name, key, version, userinstalled, enabled | ft 13 | 14 | <# 15 | Using the api $ curl -u admin:admin -basic http://localhost:2990/jira/rest/plugins/1.0/ { "plugins":[ { "enabled":true, "name":"Admin Menu Sections", "userInstalled":false, "description":"This library includes the web fragments for the administration menu", "links":{ "modify":"/jira/rest/plugins/1.0/jira.webfragments.admin-key", "delete":"/jira/rest/plugins/1.0/jira.webfragments.admin-key" }, }, ... ], "links":{ "available":"/jira/rest/plugins/1.0/available", "upgrades":"/jira/rest/plugins/1.0/available/upgrades", "enter-safe-mode":"/jira/rest/plugins/1.0/safe-mode", "install":"/jira/rest/plugins/1.0/" ... }, } 10 16 | 10. Scripting the UPM #!/usr/bin/env python from subprocess import Popen, PIPE, STDOUT import json,os nul_f = open(os.devnull, w) cmd = curl -basic -u admin:admin http://localhost:2990/jira/rest/plugins/1.0/upgrades p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=nul_f, close_fds=True) print len(json.loads(p.stdout.read())[plugins]) 11 17 | 18 | #> 19 | } 20 | } -------------------------------------------------------------------------------- /Plugins/Get-CflUpmSetting.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflUpmSetting { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $false)] 5 | [ValidateNotNull()] 6 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 7 | ) 8 | process { 9 | #Yes. The API is available at /rest/plugins/1.0/settings. Inspecting your browser's web console will get you details about the API's content type, expected payload and other details. 10 | } 11 | } -------------------------------------------------------------------------------- /PoshConfluence.Format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | PageTableView 7 | 8 | ThomyKay.Confluence.RemotePageSummary 9 | ThomyKay.Confluence.RemoteBlogEntrySummary 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | space 28 | 29 | 30 | title 31 | 32 | 33 | url 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | RemoteContentSummaryTable 42 | 43 | ThomyKay.Confluence.RemoteContentSummary 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | type 74 | 75 | 76 | space 77 | 78 | 79 | title 80 | 81 | 82 | creator 83 | 84 | 85 | created 86 | 87 | 88 | modifier 89 | 90 | 91 | modified 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /PoshConfluence.Types.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ThomyKay.Confluence.RemotePageSummary 6 | 7 | 8 | Content1 9 | 10 | $session = Get-CflSession -Current 11 | $page = $session.Proxy.getPage($session.Token, $this.space, $this.Title) 12 | $page.Content 13 | 14 | 15 | 16 | 17 | 18 | ThomyKay.Confluence.RemoteSpaceSummary 19 | 20 | 21 | PSStandardMembers 22 | 23 | 24 | DefaultDisplayPropertySet 25 | 26 | key 27 | name 28 | 29 | 30 | 31 | 32 | 33 | ToString 34 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PoshConfluence.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomykay/PoshConfluence/20408528aaa05edf6df2f264410f5c01206d31b7/PoshConfluence.psd1 -------------------------------------------------------------------------------- /PoshConfluence.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomykay/PoshConfluence/20408528aaa05edf6df2f264410f5c01206d31b7/PoshConfluence.psm1 -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomykay/PoshConfluence/20408528aaa05edf6df2f264410f5c01206d31b7/README -------------------------------------------------------------------------------- /Remove-CflSession.ps1: -------------------------------------------------------------------------------- 1 | function Remove-CflSession 2 | { 3 | [CmdletBinding()] 4 | param( 5 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 6 | [ValidateNotNull()] 7 | [ThomyKay.Confluence.CflSession]$Session 8 | ) 9 | 10 | $SessionManager.Remove($Session) 11 | } -------------------------------------------------------------------------------- /Remove-CflSpace.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/22/2011 6:20:19 PM 3 | #Script: Remove-CflSpace 4 | function Remove-CflSpace 5 | { 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | begin 16 | { 17 | } 18 | process 19 | { 20 | if ($psCmdlet.ShouldProcess($Space.Name)) 21 | { 22 | [Void]$session.Proxy.RemoveSpace($Session.Token, $Space.Key) 23 | } 24 | } 25 | end 26 | { 27 | } 28 | } -------------------------------------------------------------------------------- /Search-CflContent.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Short description 4 | .DESCRIPTION 5 | Long description 6 | .EXAMPLE 7 | Example of how to use this cmdlet 8 | .EXAMPLE 9 | Another example of how to use this cmdlet 10 | #> 11 | function Search-CflContent 12 | { 13 | [CmdletBinding()] 14 | [OutputType([int])] 15 | Param 16 | ( 17 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $false)] 18 | [string]$Query, 19 | 20 | [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true)] 21 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 22 | 23 | [Parameter(Mandatory = $false)] 24 | [ValidateNotNull()] 25 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 26 | ) 27 | 28 | begin 29 | { 30 | $parameters = New-Object ThomyKay.Confluence.Map 31 | } 32 | process 33 | { 34 | 35 | if ($Space) 36 | { 37 | $item = new-object ThomyKay.Confluence.mapItem 38 | $item.key = "spaceKey" 39 | $item.value = $Space.key 40 | $parameters.item = $item 41 | } 42 | 43 | $Session.Proxy.search($Session.Token, $Query, $parameters, 100000) 44 | } 45 | end 46 | { 47 | } 48 | } -------------------------------------------------------------------------------- /SpaceManagement/Get-CflSpaceTrash.ps1: -------------------------------------------------------------------------------- 1 | function Get-CflSpaceTrash { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory= $true, Position = 0, ValueFromPipeline = $true)] 5 | [ThomyKay.Confluence.RemoteSpaceSummary]$Space, 6 | 7 | [Parameter(Mandatory = $false)] 8 | [ValidateNotNull()] 9 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 10 | ) 11 | process { 12 | $Session.Proxy.getTrashContents($Session.Token, $Space.key,0,100000) 13 | } 14 | } -------------------------------------------------------------------------------- /UserManagement/Add-CflGroupMember.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 1:34:47 PM 3 | #Script: Add-CflGroupMember 4 | function Add-CflGroupMember { 5 | [CmdletBinding()] 6 | param ( 7 | [Parameter(Mandatory = $true, Position = 0)] 8 | [string]$GroupName, 9 | 10 | [Parameter(Mandatory = $true, Position = 1)] 11 | [string]$UserName, 12 | 13 | [Parameter(Mandatory = $false)] 14 | [ValidateNotNull()] 15 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 16 | ) 17 | process { 18 | [Void]$Session.Proxy.addUserToGroup($Session.Token, $UserName, $GroupName) 19 | } 20 | } -------------------------------------------------------------------------------- /UserManagement/Disable-CflUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/23/2011 9:50:53 PM 3 | #Script: Disable-CflUser 4 | function Disable-CflUser 5 | { 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact = "Medium")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemoteUser]$User, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | 16 | if ($psCmdlet.ShouldProcess($User.Name)) 17 | { 18 | $Session.proxy.deactivateUser($Session.Token, $User.Name) 19 | } 20 | } -------------------------------------------------------------------------------- /UserManagement/Enable-CflUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/23/2011 9:50:02 PM 3 | #Script: Enable-CflUser 4 | function Enable-CflUser 5 | { 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact = "Medium")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemoteUser]$User, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | 16 | if ($psCmdlet.ShouldProcess($User.Name)) 17 | { 18 | $Session.proxy.reactivateUser($Session.Token, $User.Name) 19 | } 20 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflGroup.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 8:06:18 PM 3 | #Script: Get-CflGroup 4 | function Get-CflGroup 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Name = "*", 10 | 11 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipelineByPropertyName = $true, ParameterSetName = "ByUser")] 12 | [string]$UserName, 13 | 14 | [Parameter(Mandatory = $false)] 15 | [ValidateNotNull()] 16 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 17 | ) 18 | process 19 | { 20 | switch ($psCmdlet.ParameterSetName) 21 | { 22 | "ByUser" { 23 | $session.Proxy.getUserGroups($session.Token, $UserName) | Where-Object {$_ -like $Name} 24 | } 25 | default { 26 | $session.Proxy.getGroups($session.Token) | Where-Object {$_ -like $Name} 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflGroupMember.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 1:44:02 PM 3 | #Script: Get-CflGroupMember 4 | function Get-CflGroupMember { 5 | param ( 6 | [Parameter(Mandatory = $true, Position = 0)] 7 | [string]$GroupName, 8 | 9 | [Parameter(Mandatory = $false, Position = 1)] 10 | [Alias("UserName")] 11 | [string]$Name = "*", 12 | 13 | [Parameter(Mandatory = $false)] 14 | [ValidateNotNull()] 15 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 16 | ) 17 | process { 18 | Get-CflUser $Name | Where-Object {$Session.Proxy.getUserGroups($Session.Token, $_.name) -contains $GroupName} 19 | } 20 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflMemberOf.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 1:44:02 PM 3 | #Script: Get-CflGroupMember 4 | function Get-CflMemberOf { 5 | param ( 6 | [Parameter(Mandatory = $true, Position = 0)] 7 | [Alias("Name")] 8 | [string]$UserName, 9 | 10 | [Parameter(Mandatory = $false, Position = 1)] 11 | [string]$GroupName = "*", 12 | 13 | [Parameter(Mandatory = $false)] 14 | [ValidateNotNull()] 15 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 16 | ) 17 | process { 18 | Get-CflUser $UserName ` 19 | | %{$Session.Proxy.getUserGroups($Session.Token, $_.name)} ` 20 | | Where-Object {$_ -like $GroupName} 21 | } 22 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflPageWatch.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 2:36:00 PM 3 | #Script: Get-CflPageWatch 4 | function Get-CflPageWatch { 5 | [CmdletBinding()] 6 | param ( 7 | [ThomyKay.Confluence.Rem 8 | [Parameter(Mandatory = $false)] 9 | [ValidateNotNull()] 10 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 11 | ) 12 | process { 13 | $Session.Proxy.getWatchersForPage 14 | } 15 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/23/2011 9:52:31 PM 3 | #Script: Get-CflUser 4 | function Get-CflUser 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Name = "*", 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | process 16 | { 17 | $Session.Proxy.getActiveUsers($Session.Token, $true) | ` 18 | Where-Object {$_ -like $Name} | ` 19 | %{$Session.Proxy.getUser($Session.Token, $_)} 20 | } 21 | } -------------------------------------------------------------------------------- /UserManagement/Get-CflUserGroup.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 2:14:42 PM 3 | #Script: Get-CflUserGroups 4 | function Get-CflUserGroup { 5 | [CmdletBinding()] 6 | param ( 7 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 8 | [ThomyKay.Confluence.RemoteUser]$User, 9 | 10 | [Parameter(Mandatory = $false)] 11 | [ValidateNotNull()] 12 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 13 | ) 14 | process { 15 | $Session.Proxy.getUserGroups($Session.Token, $User.name) 16 | } 17 | } -------------------------------------------------------------------------------- /UserManagement/New-CflGroup.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 8:04:35 PM 3 | #Script: New-CflGroup 4 | function New-CflGroup 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Name = "*", 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | process 16 | { 17 | [Void]$session.Proxy.addGroup($session.Token, $Name) 18 | } 19 | } -------------------------------------------------------------------------------- /UserManagement/New-CflUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/23/2011 9:51:44 PM 3 | #Script: New-CflUser 4 | function New-CflUser 5 | { 6 | [CmdletBinding()] 7 | param ( 8 | [Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName = $true)] 9 | [Alias("SamAccountName")] 10 | [ValidateNotNull()] 11 | [string]$Name, 12 | 13 | [Parameter(Mandatory=$true, Position = 1, ValueFromPipelineByPropertyName = $true)] 14 | [ValidateNotNull()] 15 | [string]$Password, 16 | 17 | [Parameter(Mandatory=$true, Position = 2, ValueFromPipelineByPropertyName = $true)] 18 | [Alias("DisplayName")] 19 | [ValidateNotNull()] 20 | [string]$FullName, 21 | 22 | [Parameter(Mandatory=$true, Position = 3, ValueFromPipelineByPropertyName = $true)] 23 | [ValidateNotNull()] 24 | [string]$Email, 25 | 26 | [Parameter(Mandatory = $false)] 27 | [ValidateNotNull()] 28 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 29 | ) 30 | process 31 | { 32 | $user = New-Object ThomyKay.Confluence.RemoteUser -Property @{ 33 | Name = $Name; 34 | Fullname = $FullName; 35 | Email = $Email 36 | } 37 | $Session.Proxy.addUser($Session.Token, $user, $Password, $false) 38 | } 39 | } -------------------------------------------------------------------------------- /UserManagement/Register-CflPageWatch.ps1: -------------------------------------------------------------------------------- 1 | function Register-CflPageWatch 2 | { 3 | param ( 4 | 5 | 6 | [Parameter(Mandatory = $false)] 7 | [ValidateNotNull()] 8 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 9 | ) 10 | process { 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /UserManagement/Remove-CflGroup.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/24/2011 8:05:39 PM 3 | #Script: Remove-CflGroup 4 | function Remove-CflGroup 5 | { 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 9 | [string]$Name, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | process 16 | { 17 | #TODO: Add support for defaultGroup 18 | if ($psCmdlet.ShouldProcess($Name)) 19 | { 20 | [Void]$session.Proxy.removeGroup($session.Token, $Name, $null) 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /UserManagement/Remove-CflGroupMember.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 8/6/2012 1:35:12 PM 3 | #Script: Remove-CflGroupMember 4 | function Remove-CflGroupMember { 5 | [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 6 | param ( 7 | [Parameter(Mandatory = $true, Position = 0)] 8 | [string]$GroupName, 9 | 10 | [Parameter(Mandatory = $true, Position = 1)] 11 | [string]$UserName, 12 | 13 | [Parameter(Mandatory = $false)] 14 | [ValidateNotNull()] 15 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 16 | ) 17 | process { 18 | if ($psCmdlet.ShouldProcess($UserName)) 19 | { 20 | [Void]$Session.proxy.removeUserFromGroup($Session.Token, $UserName, $GroupName) 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /UserManagement/Remove-CflUser.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 3/23/2011 10:02:10 PM 3 | #Script: Remove-CflUser 4 | function Remove-CflUser 5 | { 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact = "High")] 7 | param ( 8 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 9 | [ThomyKay.Confluence.RemoteUser]$User, 10 | 11 | [Parameter(Mandatory = $false)] 12 | [ValidateNotNull()] 13 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 14 | ) 15 | process 16 | { 17 | if ($psCmdlet.ShouldProcess($User.Name)) 18 | { 19 | [Void]$Session.proxy.removeUser($Session.Token, $User.Name) 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /UserManagement/Test-CflGroup.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Short description 4 | .DESCRIPTION 5 | Long description 6 | .EXAMPLE 7 | Example of how to use this cmdlet 8 | .EXAMPLE 9 | Another example of how to use this cmdlet 10 | #> 11 | function Test-CflGroup 12 | { 13 | [CmdletBinding()] 14 | [OutputType([bool])] 15 | Param 16 | ( 17 | # This is the group name 18 | [Parameter(Mandatory=$true, ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)] 19 | [Alias("Group","Name")] 20 | $GroupName, 21 | 22 | [Parameter(Mandatory = $false)] 23 | [ValidateNotNull()] 24 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 25 | ) 26 | 27 | begin 28 | { 29 | } 30 | process 31 | { 32 | $Session.Proxy.hasGroup($Session.Token, $GroupName) 33 | } 34 | end 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /UserManagement/Test-CflUser.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Short description 4 | .DESCRIPTION 5 | Long description 6 | .EXAMPLE 7 | Example of how to use this cmdlet 8 | .EXAMPLE 9 | Another example of how to use this cmdlet 10 | #> 11 | function Test-CflUser 12 | { 13 | [CmdletBinding()] 14 | [OutputType([bool])] 15 | Param 16 | ( 17 | # This is the user name 18 | [Parameter(Mandatory=$true, ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)] 19 | [Alias("User","Name")] 20 | $UserName, 21 | 22 | [Parameter(Mandatory = $false)] 23 | [ValidateNotNull()] 24 | [ThomyKay.Confluence.CflSession]$Session = (Get-CflSession -Current) 25 | ) 26 | 27 | begin 28 | { 29 | } 30 | process 31 | { 32 | $Session.Proxy.hasUser($Session.Token, $UserName) 33 | } 34 | end 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /UserManagement/Unregister-CflPageWatch.ps1: -------------------------------------------------------------------------------- 1 | #Author: thkrause 2 | #Date: 5/4/2012 15:11:01 3 | #Script: Unregister-CflPageWatch 4 | function Unregister-CflPageWatch { 5 | [CmdletBinding()] 6 | param ( 7 | ) 8 | process { 9 | } 10 | } --------------------------------------------------------------------------------