Dicas e informações sobre Windows Server, Powershell

Descobrindo a chave do office

E aí pessoal, tudo certo?

Tem várias licenças do office aí? Versões diferentes, várias máquinas? Perdeu o controle delas e não sabe qual está aplicada em qual máquina? Recentemente passei por algo parecido e precisei organizar algumas chaves. 

E fiz o script abaixo para me ajudar com essa demanda, com ele consigo listar os 5 últimos conjuntos de caracteres da chave. Onde consigo identificar qual é chave está aplicada no computador qual computador =D

Imagem 01 – Get-OfficeKey


Versões testadas

2016 Home and Bussiness x86/x64

2016 Professional Plus x86/x64

2013 Home and Bussiness x86/x64

Usa uma versão diferente? Deixe nos comentários!

SCRIPT

Write-Host "########################################################" 
Write-Host "########################################################" 
echo ""
echo ""


$_INFO = Get-ComputerInfo
Write-Host "Nome do computador: " $_INFO.CsName -ForegroundColor Cyan


echo ""
echo ""
Write-Host "########################################################" 
Write-Host "########################################################" 

#Variáveis abaixo mapeiam origem de instalação do pacote office, para versões 2013 e 2016
$_OFFICE2016x86 = Test-Path -Path "C:\Program Files (x86)\Microsoft Office\Office16"
$_OFFICE2015x86 = Test-Path -Path "C:\Program Files (x86)\Microsoft Office\Office15"
$_OFFICE2016x64 = Test-Path -Path "C:\Program Files\Microsoft Office\Office16"
$_OFFICE2015x64 = Test-Path -Path "C:\Program Files\Microsoft Office\Office15"

Write-Host "Script irá validará versão do office instalado e exibirá os 5 últimos números da chave do office instalado no computador do usuário"

Write-Host "########################################################" 
Write-Host "########################################################" 

Write-Host "Verificação de licença para office 2016x86" -ForegroundColor Cyan

switch ($_OFFICE2016x86){
    True {
        Write-Host "Versão do office instalada é 2016x86" -ForegroundColor Green
        Write-Host "Será exibido os 5 últimos digitos da chave de ativação do office" -ForegroundColor Green
        Cd "C:\Program Files (x86)\Microsoft Office\Office16"
        Cscript ospp.vbs /dstatus
    }
    False {
        Write-Host "VERSÃO NÃO DETECTADA" -ForegroundColor Red
    }
    Default {
        Write-Host "Houve um erro, gentileza contatar o departamento de Infra" -ForegroundColor Red
    }
}

Write-Host "########################################################" 
Write-Host "########################################################" 

Write-Host "Verificação de licença para office 2013x86" -ForegroundColor Cyan

switch ($_OFFICE2015x86){
    True {
        Write-Host "Versão do Office instalada é a 2013x86" -ForegroundColor Green
        Write-Host "Será exibido os 5 últimos digitos da chave de ativação do office" -ForegroundColor Green
        Cd "C:\Program Files (x86)\Microsoft Office\Office15"
        Cscript ospp.vbs /dstatus
    }
    False {
        Write-Host "VERSÃO NÃO DETECTADA" -ForegroundColor Red
    }
    Default {
        Write-Host "Houve um erro, gentileza contatar o departamento de Infra" -ForegroundColor Red
    }
}   

Write-Host "########################################################" 
Write-Host "########################################################" 

Write-Host "Verificação de licença para office 2016x64" -ForegroundColor Cyan

switch ($_OFFICE2016x64){
    True {
        Write-Host "Versão do office instalada é 2016x64" -ForegroundColor Green
        Write-Host "Será exibido os 5 últimos digitos da chave de ativação do office" -ForegroundColor Green
        Cd "C:\Program Files\Microsoft Office\Office16"
        Cscript ospp.vbs /dstatus
    }
    False {
        Write-Host "VERSÃO NÃO DETECTADA" -ForegroundColor Red
    }
    Default {
        Write-Host "Houve um erro, gentileza contatar o departamento de Infra" -ForegroundColor Red
    }
}


Write-Host "########################################################" 
Write-Host "########################################################" 


Write-Host "Verificação de licença para office 2013x64" -ForegroundColor Cyan

switch ($_OFFICE2015x64){
    True {
        Write-Host "Versão do Office instalada é a 2013" -ForegroundColor Green
        Write-Host "Será exibido os 5 últimos digitos da chave de ativação do office" -ForegroundColor Green
        Cd "C:\Program Files\Microsoft Office\Office15"
        Cscript ospp.vbs /dstatus
    }
    False {
        Write-Host "VERSÃO NÃO DETECTADA" -ForegroundColor Red
    }
    Default {
        Write-Host "Houve um erro, gentileza contatar o departamento de Infra" -ForegroundColor Red
    }
}   

Write-Host "########################################################" 
Write-Host "########################################################" 

Por hoje é isso =D

Tenham uma ótima semana!

1 Comment

  1. September 8, 2019    

    Hi my friend! I wish to say that this post is awesome, nice written and include almost all important infos. I would like to see more posts like this.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.