@@ -14,6 +14,9 @@ public class SetWebHeader : PnPWebCmdlet
14
14
[ Parameter ( Mandatory = false ) ]
15
15
public string SiteLogoUrl ;
16
16
17
+ [ Parameter ( Mandatory = false ) ]
18
+ public string SiteThumbnailUrl ;
19
+
17
20
[ Parameter ( Mandatory = false ) ]
18
21
public HeaderLayoutType HeaderLayout = HeaderLayoutType . Standard ;
19
22
@@ -38,18 +41,17 @@ public class SetWebHeader : PnPWebCmdlet
38
41
protected override void ExecuteCmdlet ( )
39
42
{
40
43
var requiresWebUpdate = false ;
41
-
44
+
42
45
if ( ParameterSpecified ( nameof ( SiteLogoUrl ) ) )
43
- {
44
- WriteVerbose ( $ "Setting site logo image to '{ SiteLogoUrl } '") ;
45
-
46
- var stringContent = new StringContent ( "{\" relativeLogoUrl\" :\" " + SiteLogoUrl + "\" ,\" type\" :0,\" aspect\" :1}" ) ;
47
- stringContent . Headers . ContentType = new System . Net . Http . Headers . MediaTypeHeaderValue ( "application/json" ) ;
48
- CurrentWeb . EnsureProperties ( p => p . Url ) ;
49
- var result = GraphHelper . PostAsync ( Connection , $ "{ CurrentWeb . Url . TrimEnd ( '/' ) } /_api/siteiconmanager/setsitelogo", AccessToken , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
50
- WriteVerbose ( $ "Response from setsitelogo request: { result . StatusCode } ") ;
51
- }
46
+ {
47
+ SetSiteImage ( SiteLogoUrl , "site logo" , 1 ) ;
48
+ }
52
49
50
+ if ( ParameterSpecified ( nameof ( SiteThumbnailUrl ) ) )
51
+ {
52
+ SetSiteImage ( SiteThumbnailUrl , "thumbnailurl" , 0 ) ;
53
+ }
54
+
53
55
if ( ParameterSpecified ( nameof ( LogoAlignment ) ) )
54
56
{
55
57
WriteVerbose ( $ "Setting site logo alignment to '{ LogoAlignment } '") ;
@@ -120,5 +122,15 @@ protected override void ExecuteCmdlet()
120
122
ClientContext . ExecuteQueryRetry ( ) ;
121
123
}
122
124
}
125
+ private void SetSiteImage ( string imageUrl , string imageType , int aspect )
126
+ {
127
+ WriteVerbose ( $ "Setting site { imageType } image to '{ imageUrl } '") ;
128
+
129
+ var stringContent = new StringContent ( $ "{{\" relativeLogoUrl\" :\" { imageUrl } \" ,\" type\" :0,\" aspect\" :{ aspect } }}") ;
130
+ stringContent . Headers . ContentType = new System . Net . Http . Headers . MediaTypeHeaderValue ( "application/json" ) ;
131
+ CurrentWeb . EnsureProperties ( p => p . Url ) ;
132
+ var result = GraphHelper . PostAsync ( Connection , $ "{ CurrentWeb . Url . TrimEnd ( '/' ) } /_api/siteiconmanager/setsitelogo", AccessToken , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
133
+ WriteVerbose ( $ "Response from { imageType } request: { result . StatusCode } ") ;
134
+ }
123
135
}
124
136
}
0 commit comments