WindowsServer

Powershell – Add local Administrator

If you want to add Active Directory user or group to the local administrator group on a computer, you can use Powershell.

User and Group

To add user or group, we can use the cmdlet Invoke-Command associated with net localgroup.

Invoke-Command -ScriptBlock {net Localgroup administrators /add $args[0] } -ArgumentList("LAB\alexandre")

Computer

It is also possible to add a computer account into local Administrator group, you can use the command above but don’t forget to add the $ at the end of computer name.

Invoke-Command -ScriptBlock {net Localgroup administrators /add $args[0] } -ArgumentList("LAB\SRVSCCM$")

More

You can get more informations about net localgroup here.

Share
WindowsServer

Powershell – Change computer description

To continue in Powershell posts, we will see how to change the local description of the server. Not in Active Directory attribute but on the computer itself.

System Description

The local description is set is the WMI of the server. In the class Win32_OperatingSystem. To change it, we need to get the objects, set the new content and save the modification.

$OSWMI=Get-WmiObject -class Win32_OperatingSystem
$OSWMI.Description="My Server"
$OSWMI.put()

Remote

It is possible to modify the description on a remote computer, however, we need to adapt the script if the string is store in a variable.

With the Invoke-Command we add the parameter –ArgumentList, so that our variable content will be available on the execution on the remote host.

$myDescription="My Server"
Invoke-Command -ComputerName $lServerName -ScriptBlock {$OSWMI=Get-WmiObject -class Win32_OperatingSystem;$OSWMI.Description=$args[0];$OSWMI.put() } -ArgumentList($myDescription)

More

You can get more information about Win32_OperatingSystem class here

Share
WindowsServer

Powershell – How to format all disks

Did you know that you can manage disks, partitions and volumes using Powershell? Microsoft released a lot of cmdlet in order to facilitate handling of disks.

With virtualization, you can easily add disk to your server, but you have to create the volume yourself. I wrote a script that you can integrate in your process, runbooks or others.

Disks initialization

First thing to do, is to prepare disks to host volume. We need to set disks online and to disable Read only.

try {
#Set all disks, except the first disk, to online and writable
Get-Disk | ?{$_.number -ne 0}| Set-Disk -IsOffline $False
Get-Disk | ?{$_.number -ne 0}| Set-Disk -isReadOnly $False
 
#Initialize all disks
Get-Disk | ?{$_.number -ne 0}| Initialize-Disk -PartitionStyle GPT
}catch{
Write-Host $_.Exception.Message
}

Volume

Once disks are ready, we need to create, and format volume.

try {
#Create Partition on all disk, auto assign letter and use maximum size
Get-Disk | ?{$_.number -ne 0}| New-Partition -AssignDriveLetter -UseMaximumSize
#Get all partitions and format them
Get-Disk | ?{$_.number -ne 0}| Get-Partition |?{$_.type -like "Basic"}| Format-Volume -Confirm:$false
}catch{
Write-Host $_.Exception.Message
}

Remote

If you want to execute these command on a remote host, it is possible. We will use the cmdlet Invoke-Command

try {
#Set all disks, except the first disk, to online and writable
Invoke-Command -ComputerName $lServerName -ScriptBlock {Get-Disk | ?{$_.number -ne 0}| Set-Disk -IsOffline $False}
Invoke-Command -ComputerName $lServerName -ScriptBlock {Get-Disk | ?{$_.number -ne 0}| Set-Disk -isReadOnly $False}
#Initialize all disks
Invoke-Command -ComputerName $lServerName -ScriptBlock {Get-Disk | ?{$_.number -ne 0}| Initialize-Disk -PartitionStyle GPT}
#Create Partition on all disk, auto assign letter and use maximum size
Invoke-Command -ComputerName $lServerName -ScriptBlock {Get-Disk | ?{$_.number -ne 0}| New-Partition -AssignDriveLetter -UseMaximumSize}
#Get all partitions and format them
Invoke-Command -ComputerName $lServerName -ScriptBlock {Get-Disk | ?{$_.number -ne 0}| Get-Partition |?{$_.type -like "Basic"}| Format-Volume -Confirm:$false }			
}catch{
Write-Host  $_.Exception.Message
}

More

You can get more information about Disk Management cmdlet here.

Share
Active Directory 2012

Active Directory – Create OU using Powershell

Sometimes, you need to create a lot of Organization Units into your Active Directory.
To do this, you can use the Active Directory Users and Computers but it can be quickly time consuming depends on the number of OU.

Hopefully, Microsoft integrated a powershell module with Active Directory. So, we can create a script to do this for us.

Continue reading

Share
WindowsServer

Server – Internet Explorer GPO not applied

With Active Directory, you can deploy some Internet Explorer configuration using Group Policy (GPO). But sometime, settings for Internet Explorer are not modified, even if the GPO is correctly applied.

This behavior is not a bug, it’s a feature 🙂 When IE Security is enabled, GPO can’t change configuration for Internet Explorer.
Continue reading

Share
WindowsServer

DNS – Remove WPAD Filtering

When you want to deploy an autodiscover proxy configuration for your clients, you can use WPAD with DNS.
However Windows Server DNS can reply non-existent domain for an wpad domain name request.

DNS WPAD Filtering

WPAD record in DNS


DNS WPAD Filtering

Non Existant domain


This behavior is by default and can be decomposed in two parts:

  • If WPAD configuration is already in place when you install the DNS server, no action is required.
  • When you want to set up a new WPAD configuration after DNS installation, you need to edit the block list on all your DNS servers.

Continue reading

Share
Windows 8.1

Windows 8.1 – Disable Wireless Setup

Wireless Setup

When you deploy Windows 8.1 on computers which have a Wifi adapter, there is a step in the Setup Wizard to choose the Wifi network, even if ethernet card is active.

Wireless Setup

Wireless Setup

This step can block a SCCM task sequence or a MDT deployment because the Wizard asks for an action.

Fortunately, this step can be bypass/disabled by using an unattend.xml file.

Continue reading

Share
SCCM

SCCM 2012 – Application Catalog prompts Credentials

With System Center Configuration Manager 2012, there is a new  functionality: Application Catalog. Using Application Catalog, you can deploy an application on user collection, and all users can use this web page to install or request an application.

Credentials prompt

To launch the Application Catalog, you can use the existing link on Software Center:

Application Catalog link Software center

Link Software center

Depends on your system configuration, Internet Explorer can prompt for your login / password. Even if you are in your domain.

Application Catalog Prompt

Credential Prompt

Continue reading

Share
SCCM

SCCM 2012 – How to deploy App-V 5 Agent

If you want to deploy the App-V 5 Agent on your computers, you can use System Center Configuration Manager (SCCM) 2012. The most easily method is to use an Application. By this way, you have the possibility to link some Dependencies and target specific operating system architecture (x64 or x86).

To deploy App-V 5 agent, you have to follow these steps:

  1. Configure Dependencies.
  2. Create Application.
  3. Configure Deployments type for x64 and x86.
  4. Deploy on a collection.
  5. Check installation.

Continue reading

Share