Skip to content

Commit 03c8daf

Browse files
authored
Update CopyAttachments.ps1
1 parent 182366e commit 03c8daf

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

Items Management/Attachments/Copy list attachments to a separate library/CopyAttachments.ps1

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
function Get-SPOListFields{
2-
<#
2+
<#
33
.link
44
http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx
5-
6-
#>
5+
#>
76

87
param (
9-
[Parameter(Mandatory=$true,Position=3)]
10-
[string]$ListTitle,
11-
[Parameter(Mandatory=$false,Position=4)]
12-
[bool]$IncludeSubsites=$false
13-
)
8+
[Parameter(Mandatory=$true,Position=3)]
9+
[string]$ListTitle,
10+
[Parameter(Mandatory=$false,Position=4)]
11+
[bool]$IncludeSubsites=$false
12+
)
1413

1514
$ll=$ctx.Web.Lists.GetByTitle($ListTitle)
1615
$ctx.Load($ll)
@@ -52,16 +51,16 @@ function Get-SPOListItems{
5251
#>
5352

5453
param (
55-
[Parameter(Mandatory=$true,Position=1)]
56-
[string]$ListTitle,
57-
[Parameter(Mandatory=$false,Position=2)]
58-
[bool]$IncludeAllProperties=$false,
59-
[switch]$Recursive,
60-
[Parameter(Mandatory=$false,Position=4)]
61-
$DestinationLibrary,
62-
[Parameter(Mandatory=$false,Position=5)]
63-
[bool]$Overwrite
64-
)
54+
[Parameter(Mandatory=$true,Position=1)]
55+
[string]$ListTitle,
56+
[Parameter(Mandatory=$false,Position=2)]
57+
[bool]$IncludeAllProperties=$false,
58+
[switch]$Recursive,
59+
[Parameter(Mandatory=$false,Position=4)]
60+
$DestinationLibrary,
61+
[Parameter(Mandatory=$false,Position=5)]
62+
[bool]$Overwrite
63+
)
6564

6665

6766
$ll=$ctx.Web.Lists.GetByTitle($ListTitle)
@@ -70,8 +69,6 @@ function Get-SPOListItems{
7069
$ctx.ExecuteQuery()
7170
$i=0
7271

73-
74-
7572
$spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
7673
# $spqQuery.ViewAttributes = "Scope='Recursive'"
7774
$spqQuery.ViewXml = "<Where><Eq><FieldRef Name='Attachments' /><Value Type='Boolean'>1</Value></Eq></Where>";
@@ -95,7 +92,8 @@ function Get-SPOListItems{
9592
$ctx.Load($attache)
9693
$ctx.ExecuteQuery()
9794
Write-Host $itemki[$j]["Title"] -BackgroundColor DarkCyan
98-
foreach($att in $attache){
95+
96+
foreach($att in $attache){
9997
#Write-Output $att
10098
$file =
10199
$ctx.Web.GetFileByServerRelativeUrl($att.ServerRelativeUrl);
@@ -112,7 +110,6 @@ function Get-SPOListItems{
112110

113111
try{
114112
$ctx.ExecuteQuery()
115-
116113
Write-Host $file.Name " has been copied to" $DestinationLibrary -ForegroundColor DarkGreen
117114
}
118115
catch [Net.WebException]{
@@ -127,8 +124,7 @@ function Connect-SPOCSOM{
127124
<#
128125
.link
129126
http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx
130-
131-
#>
127+
#>
132128

133129
param (
134130
[Parameter(Mandatory=$true,Position=1)]

0 commit comments

Comments
 (0)