File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -153,12 +153,30 @@ protected override void ExecuteCmdlet()
153
153
154
154
if ( ParameterSpecified ( nameof ( ScriptSafeDomainName ) ) && ! string . IsNullOrEmpty ( ScriptSafeDomainName ) )
155
155
{
156
- ScriptSafeDomainEntityData scriptSafeDomainEntity = new ScriptSafeDomainEntityData
156
+ ScriptSafeDomain safeDomain = null ;
157
+ try
157
158
{
158
- DomainName = ScriptSafeDomainName
159
- } ;
160
- site . CustomScriptSafeDomains . Create ( scriptSafeDomainEntity ) ;
161
- context . ExecuteQueryRetry ( ) ;
159
+ safeDomain = ClientContext . Site . CustomScriptSafeDomains . GetByDomainName ( ScriptSafeDomainName ) ;
160
+ ClientContext . Load ( safeDomain ) ;
161
+ ClientContext . ExecuteQueryRetry ( ) ;
162
+ }
163
+ catch { }
164
+ if ( safeDomain . ServerObjectIsNull == null )
165
+ {
166
+ ScriptSafeDomainEntityData scriptSafeDomainEntity = new ScriptSafeDomainEntityData
167
+ {
168
+ DomainName = ScriptSafeDomainName
169
+ } ;
170
+
171
+ safeDomain = context . Site . CustomScriptSafeDomains . Create ( scriptSafeDomainEntity ) ;
172
+ context . Load ( safeDomain ) ;
173
+ context . ExecuteQueryRetry ( ) ;
174
+ WriteObject ( safeDomain ) ;
175
+ }
176
+ else
177
+ {
178
+ WriteWarning ( $ "Unable to add Domain Name as there is an existing domain name with the same name. Will be skipped.") ;
179
+ }
162
180
}
163
181
164
182
if ( ParameterSpecified ( nameof ( LogoFilePath ) ) )
You can’t perform that action at this time.
0 commit comments