At the company where I work, I'm trying to carry out a process that is to show an image to the user when they turn on the computer, it's a PowerShell script.
Our employees are in Active Directory and I have already created the GPO to pull the script when connecting the employees' PC, but when it runs a message appears:
I have already created the GPO in AD and I have already done the script, I have already given the necessary permissions in the Group Policy Editor.
We carried out tests and it is running when the PC is turned on, but this message simply appears instead of running automatically. I don't want the user to have to press YES on the screen to see the content.
Any tips, help, anything I can do?
This is the code of powersheel that I created:
ExecutionPolicy LocalMachine
# Carrega as assemblies necessárias
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Caminho real da sua imagem no servidor
$imagemPath = "\\192.168.0.175\Arquivos Z\_Scripts\imagemAlerta.jpeg"
# Tenta carregar a imagem
try {
$imagem = [System.Drawing.Image]::FromFile($imagemPath)
$larguraImagem = $imagem.Width/1.4
$alturaImagem = $imagem.Height/1.4
} catch {
# Em caso de erro ao carregar a imagem, exibe uma mensagem de erro
[System.Windows.Forms.MessageBox]::Show("Erro ao carregar a imagem.", "Erro", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
exit
}
# Exibe uma caixa de mensagem com a imagem e um botão "OK"
$form = New-Object Windows.Forms.Form
$form.Text = "MENSAGEM DE AVISO!"
$form.Size = New-Object Drawing.Size @($larguraImagem, $alturaImagem)
$form.StartPosition = "CenterScreen"
$pictureBox = New-Object Windows.Forms.PictureBox
$pictureBox.Image = $imagem
$pictureBox.SizeMode = "StretchImage"
$pictureBox.Dock = "Fill"
# Adiciona PictureBox ao formulário
$form.Controls.Add($pictureBox)
# Adiciona botão "OK" ao formulário
$buttonOK = New-Object Windows.Forms.Button
$buttonOK.Text = "Clique para fechar"
$buttonOK.Dock = "Top"
$buttonOK.TextAlign = "Right"
$buttonOK.add_Click({
$form.Close()
})
# Adiciona botão "OK" ao formulário
$form.Controls.Add($buttonOK)
# Exibe a janela
$form.ShowDialog()
But then, this code is a script logon at group policy in AD, but when it's executed appears that message that I mentioned above.
I'm modifyfing this code, but what I'd like to do with this would be create a code which users can click "Ok" in a box to confirm the reading.

Pls run the script as