Advertisement
Kalidor_Vorlich

ps office arch on remote

Dec 20th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Define the target remote machine
  2. $remoteComputer = "RemoteMachineName"  # Replace with the target machine's name or IP
  3.  
  4. # Define the registry paths for Office bitness
  5. $officePaths = @(
  6.     "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration",
  7.     "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot",
  8.     "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Office\16.0\Common\InstallRoot"
  9. )
  10.  
  11. # Function to check Office bitness
  12. function Get-OfficeBitness {
  13.     param (
  14.         [string]$computerName
  15.     )
  16.     Invoke-Command -ComputerName $computerName -ScriptBlock {
  17.         param ($paths)
  18.         foreach ($path in $paths) {
  19.             if (Test-Path $path) {
  20.                 $bitness = Get-ItemProperty -Path $path | Select-Object -ExpandProperty Bitness -ErrorAction SilentlyContinue
  21.                 if ($bitness) {
  22.                     return $bitness
  23.                 }
  24.             }
  25.         }
  26.         return "Office not found or Bitness not detected."
  27.     } -ArgumentList $officePaths
  28. }
  29.  
  30. # Call the function and display results
  31. $bitness = Get-OfficeBitness -computerName $remoteComputer
  32. Write-Host "Microsoft Office on $remoteComputer is $bitness." -ForegroundColor Green
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement