13 février 2017 1 13 /02 /février /2017 12:01

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$POSTE=Read-Host "Nom du poste à checker?"
$RAM = [Math]::Round((Get-WmiObject -Class win32_computersystem -ComputerName $POSTE).TotalPhysicalMemory/1Gb)
[System.Windows.MessageBox]::Show("Il y a $RAM Giga de RAM sur le poste")

Partager cet article

Repost 0
10 février 2017 5 10 /02 /février /2017 09:21

Import-Module ActiveDirectory
$Results = Get-ADUser -filter { enabled -eq $False } –properties Name,Created,LastLogonDate,Samaccountname,Title,Department |select-object Name,Created,LastLogonDate,Samaccountname,Title,Department | export-csv –path c:\TEMP\\Get-ADUser_Disablet.csv –delimiter ";"
 

Partager cet article

Repost 0
9 février 2017 4 09 /02 /février /2017 14:40


$oReturn=[System.Windows.Forms.MessageBox]::Show("Message Text","By Yasin",[System.Windows.Forms.MessageBoxButtons]::OKCancel)

switch ($oReturn){

    "OK" {

        write-host "Vous avez valider"

        # Enter some code

    }

    "Cancel" {

        write-host "Vous avez annuler"

        # Enter some code

    }
}

Partager cet article

Repost 0
18 juin 2015 4 18 /06 /juin /2015 23:13

# PowerShell script de sauvegarde de profil by Geekers
# Requires -RunAsAdministrator
Enable-PSRemoting -Force
Clear-Host


Enable-PSRemoting


New-Item -Path "Registry::HKEY_CLASSES_ROOT\Microsoft.PowershellScript.1\Shell\runas\command" `
-Force -Name '' -Value '"c:\windows\system32\windowspowershell\v1.0\powershell.exe" -noexit "%1"'

Set-ExecutionPolicy Bypass


# Set-ExecutionPolicy Bypass -scope LocalMachine
# Set-ExecutionPolicy Bypass -scope MachinePolicy
# Set-ExecutionPolicy Bypass -scope UserPolicy
# Set-ExecutionPolicy Bypass -scope Process
# Set-ExecutionPolicy Bypass -scope CurrentUser


# memorise juste le nom du profil


$User = [Environment]::UserName
$Computer = [System.Net.Dns]::GetHostName()
$Desktop = "$ENV:USERPROFILE\desktop"
$Documents = "$ENV:USERPROFILE\documents"
$Pictures = "$ENV:USERPROFILE\Pictures"
$Downloads = "$ENV:USERPROFILE\Downloads"
$Favorites = "$ENV:USERPROFILE\Favorites"
#$AppMicrolocal = "$ENV:USERPROFILE\Appdata\Local\Microsoft\"
$LocalOutlook = "$ENV:USERPROFILE\Appdata\Local\Microsoft\Outlook"
#$AppMicroroaming = "$ENV:USERPROFILE\Appdata\Roaming\Microsoft"
$RoamOutlook = "$ENV:USERPROFILE\Appdata\Roaming\Microsoft\Outlook"
$Music = "$env:userprofile\music"
$profil = "$env:userprofile"
$contact = "$env:userprofile\contacts"


Invoke-Command -ComputerName $Computer -ScriptBlock {powershell \\moya\transferts\Geekers\Support\Save_Profil_ok.ps1}


#Enter-PSSession -ComputerName $Computer -Credential localhost\administrateur


# Logiciel divers


$Log_gmc = "$env:userprofile\gmc"
$Log_Promark = "$env:userprofile\.promark"
$Log_TT_logfiles = "c$\tt\logfiles"
$Log_TT_ttconfig = "c$\tt\datfiles\TTCONFIG"
$Log_TT_config = "c$\tt\config"


$Source = "$env:userprofile\"
# C:\Users\geekers\
$SourceFinal = "$env:userprofile\Desktop\" + [System.Net.Dns]::GetHostName()
# C:\Users\geekers\Desktop\pc-geekers
$DestFinal = "\\pc-geekers\PARTAGE\"
# \\pc-geekers\PARTAGE\
$Dest = "$ENV:USERPROFILE\desktop"
# C:\Users\geekers\desktop


# creer dossier dans dossier destination sous nom du profil


#$Dest1 = New-Item -path $Dest -Name $Computer -ItemType directory -force
$Dest1 = New-Item -path $DestFinal -Name $Computer -ItemType directory -force
$Dest2 = New-Item -path $Dest1 -Name $User -ItemType directory -force
$DestFinal2 = New-Item -path $DestFinal -Name $Computer -ItemType directory -force


# copie vers dest des dossiers suivants


Copy-Item $Music $Dest2 -Recurse
Copy-Item $Favorites $Dest2 -Recurse
Copy-Item $Desktop c:\apps\ -Recurse
Copy-Item $Documents $Dest2 -Recurse
Copy-Item $Pictures $Dest2 -Recurse
Copy-Item $Download $Dest2 -Recurse
Copy-Item $LocalOutlook $Dest2 -Recurse
Copy-Item $RoamOutlook $Dest2 -Recurse
Copy-Item $Log_gmc $Dest2 -Recurse
Copy-Item $Log_Promark $Dest2 -Recurse
Copy-Item $Log_TT_logfiles $Dest2 -Recurse
Copy-Item $Log_TT_ttconfig $Dest2 -Recurse
Copy-Item $Log_TT_config $Dest2 -Recurse


# Copy-Item $Dest2 $DestFinal2 -Recurse


# Remove-Item -path $SourceFinal -Force -Recurse

Partager cet article

Repost 0