Last active
March 18, 2021 06:58
-
-
Save joerodgers/e36632268a8c3d3dc027a1d7fb9279a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AdalSettings | |
{ | |
[CmdletBinding()] | |
param() | |
begin | |
{ | |
$assemblies = @( "ADAL.dll", "MSO.dll", "CSI.dll" ) | |
} | |
process | |
{ | |
$settings = [PSCustomObject] @{ | |
ComputerName = $env:COMPUTERNAME | |
UserName = $env:USERNAME | |
EnableADALDWord = "NOT FOUND" | |
"Designer (x86)" = (Test-Path -Path "C:\Program Files (x86)\Microsoft Office\Office15\SPDESIGN.EXE" -PathType Leaf) | |
"Designer (x64)" = (Test-Path -Path "C:\Program Files\Microsoft Office\Office15\SPDESIGN.EXE" -PathType Leaf) | |
"InfoPath (x86)" = (Test-Path -Path "C:\Program Files (x86)\Microsoft Office\Office15\INFOPATH.EXE" -PathType Leaf) | |
"InfoPath (x64)" = (Test-Path -Path "C:\Program Files\Microsoft Office\Office15\INFOPATH.EXE" -PathType Leaf) | |
} | |
foreach( $assembly in $assemblies ) | |
{ | |
$propertyName = "$assembly (x86)" | |
$settings | Add-Member -MemberType NoteProperty -Name $propertyName -Value "NOT FOUND" | |
$x86AssemblyPath = Join-Path -Path "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15\" -ChildPath $assembly | |
$x86Assembly = Get-Item -Path $x86AssemblyPath -ErrorAction SilentlyContinue | |
if( $x86Assembly ) | |
{ | |
$settings.$propertyName = $x86Assembly.VersionInfo.ProductVersion | |
} | |
$propertyName = "$assembly (x64)" | |
$settings | Add-Member -MemberType NoteProperty -Name $propertyName -Value "NOT FOUND" | |
$x64AssemblyPath = Join-Path -Path "C:\Program Files\Common Files\Microsoft Shared\OFFICE15\" -ChildPath $assembly | |
$x64Assembly = Get-Item -Path $x64AssemblyPath -ErrorAction SilentlyContinue | |
if( $x64Assembly ) | |
{ | |
$settings.$propertyName = $x64Assembly.VersionInfo.ProductVersion | |
} | |
} | |
if( Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Office\15.0\Common\Identity" ) | |
{ | |
try | |
{ | |
$settings.EnableADALDWord = Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Office\15.0\Common\Identity" -Name "EnableADAL" -ErrorAction Stop | SELECT -ExpandProperty EnableADAL | |
} | |
catch | |
{ | |
if( $_ -notmatch "Property EnableADAL does not exist at path" ) | |
{ | |
Write-Error $_ | |
} | |
} | |
} | |
return $settings | |
} | |
end | |
{ | |
} | |
} | |
Get-AdalSettings | FL * | |
# example to create and set EnableADAL DWORD to 1 | |
# New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Office\15.0\Common\Identity" -Name "EnableADAL" -PropertyType DWORD -Value 1 -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment