Wednesday, May 25, 2016

HP 1910 Advanced CLI

To access the switch advanced CLI at console type:
_cmdline-mode on
pass: 512900
type - ? to see available advanced commands.

Tuesday, May 17, 2016

Check Windows Updates

sometimes you need to check does a server has a update, here the powershell script:
param ($myServer,$myHotFix)
$kb=$false
$myKBs=icm $myServer {get-hotfix}
foreach ($item in $myKBs)
{
    if ($item.HotFixId -eq $myHotFix){
        $item
        $kb=$true}
}
if ($kb -eq $false) {write "No such KB"}


It can be checked from one line:
icm "servername" {get-hotfix|where {$_.HotFixId -eq "KBnumber"}}


Exchange 2013 DAG index problem

At my customer DAG database indexes get sometimes failed or "failedandsuspended" status.
Solution was: https://support.microsoft.com/en-us/kb/2807668
So, I created the AD group "ContentSubmitters" in "Microsoft Exchange Security Groups" OU  with security:
"Network service", "Domain Admins", "Administrators" - Full Control
Propagated through AD DCs, Restarted "Microsoft Exchange Search" and "Microsoft Exchange Search Host Controller" services on all servers in the DAG.
It will take time to settle down, during the time active databases might be moved between servers by the process.

Wednesday, May 11, 2016

Can't deploy RDS services

On new 2012 R2 server cannot deploy RDS (Quick start) option. The installation times out.
The problem was - in the customer AD GPO (in my case "Default Domain Policy" differed from original default version) did not include under (Computer Configuration - Policies - Windows Settings - Security Settings - Local Policies/User Rights Assignment - Log on as a service) "NT Service\ALL SERVICES" account. The account is needed to configure "Windows Internal Database" service. By default the service running under "NT SERVICE\MSSQL$MICROSOFT##WID" account and if the account does not have rights for logon the service will fail to start.

Monday, February 08, 2016

Install .Net 3.5 on Windows 2012 R2 server


To install .Net 3.5 on Windows 2012 R2 server you need to mount Windows 2012 R2 dvd and point installation on "dvd"\sorce\sxs directory - in Powershell it will be like this:
 
Add-WindowsFeature NET-Framework-Core -Source d:\sources\sxs

Tuesday, February 02, 2016

Make-USB-Bootable


# Before running the script check USB key disk number with get-disk command, run the script from
# elevated shell
# tested only on Powershell version 5.
# after you can use robocopy to copy whatever you want to boot, the command options will be:
# robocopy "source" "destination" /mir /xd "System Volume Information" "$Recycle.bin"
param($disk_number,$DriveLetter)
Clear-Disk -Number $disk_number -RemoveData
New-Partition -DiskNumber $disk_number -UseMaximumSize -IsActive -DriveLetter $DriveLetter
Format-Volume –FileSystem NTFS –DriveLetter $DriveLetter
set-location $env:windir\system32
.\bootsect.exe /NT60 ($DriveLetter+":")

Thursday, January 28, 2016

Dismount VM's DVD on Hyper-V Cluster

$myNodes="node1","node2","node3"
foreach ($node in $myNodes)
{
    $dvd=get-vm -ComputerName $node |Get-VMDvdDrive
    foreach ($item in $dvd)
    {
        if ($item.path -ne $null)
        {
            $myDVD=[array]$myDVD+$item
        }
    }
    Foreach ($item in $myDVD)
    {
        Set-VMDvdDrive $item -path $null
    }
}

Wednesday, October 23, 2013

Powershell script to copy selected directories with use of robocopy


#The script to Archive files from one share to another depending from the file last write time (preserving the source directory structure and security)

$mySourceRoot="source directory"
$myDestRoot="destination directory"
set-location $mySourceRoot
$myDir=Get-ChildItem
$mySortDir=@()
foreach ($arg in $myDir)
{
   
    $myType=$arg.GetType()
    #write $arg.LastWriteTime
   
    if ($mytype.Name -eq "DirectoryInfo")
    {
        if ($arg.LastWriteTime -lt (get-date 2009-01-01))
        {
            write $arg.Name  $arg.lastWritetime
            $mySortDir=$mySortDir+$arg
        }
    }
}
set-location c:\windows\system32
foreach ($arg in $mySortDir)
{
    $myPath=$arg.FullName
    $myDestPath=$myPath.Replace($mySourceRoot,$myDestRoot)
    .\robocopy.exe $myPath $myDestPath /mir /sec /r:0 | Out-Null
}