SOLVED

Prepare-PlacesEnablement script fails with "Cannot overwrite variable false because it is read-only"

Copper Contributor

From the instructions on 

https://learn.microsoft.com/en-us/deployoffice/places/deployment-guide-for-places

PS C:\Users\Administrator> Install-Script -Name Prepare-PlacesEnablement -RequiredVersion 1.0
Untrusted repository
You are installing the scripts from an untrusted repository. If you trust this repository,
change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you
want to install the scripts from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a
PS C:\Users\Administrator> Prepare-PlacesEnablement
WriteError: C:\Users\Administrator\Documents\PowerShell\Scripts\Prepare-PlacesEnablement.ps1:52
Line |
52 | [bool]$PlacesMobileApp = $false,
| ~~~~~~~
| Cannot overwrite variable false because it is read-only or constant.
PS C:\Users\Administrator>

Script contents:

 

 

<#PSScriptInfo

.VERSION 1.0

.GUID 4426682f-fed2-47fe-9a75-7d61f1764139

.AUTHOR jayam

.COMPANYNAME

.COPYRIGHT

.TAGS

.LICENSEURI

.PROJECTURI

.ICONURI

.EXTERNALMODULEDEPENDENCIES

.REQUIREDSCRIPTS

.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES


.PRIVATEDATA

#>

<#

.DESCRIPTION
This script enables the groups created by the PreparePlacesGroups script with their corresponding Places features

#>

Param()



param (
[Alias("Places Web", "Places Web App")]
[bool]$PlacesWebApp = $true,
[Alias("Places Advanced Features", "PlacesPremium")]
[bool]$PlacesAdvancedFeatures = $false,
[Alias("Places Mobile", "PlacesMobile")]
[bool]$PlacesMobileApp = $false,
[Alias("Places Analytics Users", "AnalyticsUsers")]
[bool]$PlacesAnalytics = $false
)

$modules = Get-Module
$placesInstalled = $false

 

 

 

Environment is Server 2022

PowerShell 7.4.3

Exchange Tentant is a couple of years old.

11 Replies

I encountered the same issue this morning when attempting to run this script. Does the script need to be updated, or is something in our environment needing attention? Thanks!

@tjhdev2024 

 

Please do the following:

 

  1. Check Variable Names: Ensure that the variable you are trying to modify is correctly named and not a reserved keyword or system variable.

  2. Scope of Variables: Verify the scope of the variable. If it is defined outside the current script, make sure it is accessible within the script.

  3. Variable Assignment: Double-check the line where the variable is assigned. Ensure that there are no typos or syntax errors.

  4. Script Dependencies: Review any dependencies or prerequisites for the Prepare-PlacesEnablement script. Make sure all required modules or functions are available.

  5. Repository Trust: If you are installing scripts from an untrusted repository, consider changing the InstallationPolicy value using the Set-PSRepository cmdlet.

This is a Microsoft supplied script, there is nothing for me to check.
I tried the same script later on with no modifications and it worked. Not sure what changed?
best response confirmed by BrettGiammona (Microsoft)
Solution
Hey all, we have posted updated scripts that should resolve this issue. Please check the latest instructions and commands here: https://learn.microsoft.com/en-us/deployoffice/places/deployment-guide-for-places

@BrettGiammona I downloaded the latest script, but unfortunately the same error appears

baczer_0-1720082280705.png

 

Confirming that I'm also still getting the error message with the new scripts.

Try script version 4.0 and let me know if that works:

Install-Script -Name Prepare-PlacesEnablement -RequiredVersion 4.0 -Force

 

PowerShell Gallery | Prepare-PlacesEnablement 4.0

@BrettGiammona Version 4 does not produce a PowerShell error message, and defaults all params to False.  A single parameter set to true is processed as expected.

PS C:\Users\Administrator> Prepare-PlacesEnablement
$
PS C:\Users\Administrator> Prepare-PlacesEnablement -placesmobileapp $true
$
Enabling the group that can use the Places iOS App
Looking for group - Places Mobile Users [8C8BF34B-6BB8-4441-A911-3A990C9D838B]
Update completed successfully. To check the information updated please use the next cmdlet which reads updated values of settings from store.
Get-PlacesSettings -ReadFromPrimary
WARNING: The settings are read from a cached storage for upto 12 hours.

 

That looks right. You can override the default params to True for any features you wish to turn on.

@BrettGiammona 

The new script still doesn't work, same error 

 

...Prepare-PlacesEnablement.ps1 -PlacesWebApp $true -PlacesAdvancedFeatures $true -PlacesAnalytics $true -PlacesMobileApp $true
WriteError: C:\Users\mparc\Documents\PowerShell\Scripts\Prepare-PlacesEnablement.ps1:52
Line |
52 | [bool]$PlacesMobileApp = $false,
| ~~~~~~~
| Cannot overwrite variable false because it is read-only or constant.

1 best response

Accepted Solutions
best response confirmed by BrettGiammona (Microsoft)
Solution
Hey all, we have posted updated scripts that should resolve this issue. Please check the latest instructions and commands here: https://learn.microsoft.com/en-us/deployoffice/places/deployment-guide-for-places

View solution in original post