##################################################################### ##################################################################### ##################################################################### # This file will update config files for enterprise deployments. It # # can be used for Mac or Windows envrionments provided powershell 5+# ##### is installed. Please see https://aka.ms/pscore6 ############### ##################################################################### ##################################################################### #Please select where you would like the library & Styles for Windows systems #Please end the path with a \ $winLocation = "C:\Users\$env:USERNAME\Documents\" #Please select where you would like the library for Macintosh systems #Please end the path with a / $macLocation = "/Users/$env:USER/Documents/" #Windows Configuration function WindowsConfig { #Find the file $readcubeWinFile = "$env:APPDATA\Papers\config.json" if (Test-Path -Path $readcubeWinFile) { Write-Host "File found at $readcubeWinFile" #file found continue script } else { Write-Host "Config File Missing. Stopping Script..." exit } #grab the json file into raw memory $readcubeJSON = Get-Content $readcubeWinFile -raw | ConvertFrom-Json #update the paths to the following $readcubeJSON.stylesPath = $winLocation + "Paper Styles" $readcubeJSON.libraryPath = $winLocation + "Papers Libary" Write-Host "File locations have been updated." Write-Host "Styles New Path = " $readcubeJSON.stylesPath Write-Host "Library New Path = " $readcubeJSON.libraryPath $readcubeJSON | ConvertTo-Json -depth 32| set-content $readcubeWinFile Write-Host "File Saved. Script Exiting..." exit } function MacConfig { #Mac Configuration $readcubeMacFile = "~/Library/Application Support/Papers/config.json" if (Test-Path -Path $readcubeMacFile) { Write-Host "File found at $readcubeMacFile" #file found continue script } else { Write-Host "Config File Missing. Stopping Script..." exit } $readcubeJSON = Get-Content $readcubeMacFile -raw | ConvertFrom-Json #update the paths to the following $readcubeJSON.stylesPath = $macLocation + "Papers Styles" $readcubeJSON.libraryPath = $macLocation + "Papers Library" Write-Host "File locations have been updated." Write-Host "Styles New Path = " $readcubeJSON.stylesPath Write-Host "Library New Path = " $readcubeJSON.libraryPath $readcubeJSON | ConvertTo-Json -depth 32| set-content $readcubeMacFile Write-Host "File Saved. Script Exiting..." exit } if($IsWindows) { Write-Host "Detected Windows environment. Powershell 6+" WindowsConfig } else{ if($IsMacOS) { Write-Host "Detected Macintosh environment" MacConfig } else{ try { $simplePSVersion = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion } catch { Write-Host "Unsuported Operating System detected. Script Exiting" } if ($simplePSVersion) { Write-Host "Windows but powershell is lower than 6. V:$simplePSVersion" WindowsConfig else { Write-Host "Unsupported Operating System detected. Script Exiting...." exit } } } }