Thursday, March 26, 2015

Test Network Access Ports with Powershell

$Ipaddress= Read-Host "Enter the IP address:"
$Port= Read-host "Enter the port number to access:"

$t = New-Object Net.Sockets.TcpClient
$t.Connect($Ipaddress,$Port)
    if($t.Connected)
    {
        "Port $Port is operational"
    }
    else
    {
        "Port $Port is closed, You may need to contact your IT team to open it. "
        }

Tuesday, October 28, 2014

VB Script to Obtain Group Policies Applied To a Computer Remotley

Set GPM = CreateObject("GPMgmt.GPM")
Set Constants = GPM.GetConstants()
Set gpmRSOP = GPM.GetRSOP(Constants.RSOPModeLogging,"",0)
gpmRSOP.LoggingComputer = "Computername"
outputPath = "Filename.htm"
gpmRSOP.LoggingFlags = Constants.RsopLoggingNoUser
gpmRSOP.CreateQueryResults
gpmRSOP.GenerateReportToFile Constants.ReportHTML,outputPath

Saturday, August 2, 2014

Create Hyper-V Machines with Powershell


# This script creates a new Hyper-V machine with hard drive, memory & network resources configured. # Variables $SRV1 = Read-Host "Enter the Virtual Machine name (Press [Enter] to choose Server01): " if ($SRV1 -eq ""){$SRV1="Server01"} ; if ($SRV1 -eq $NULL){$SRV1="Server01"} $SRAM = Read-Host "Enter the size of the Virtual Machine Memory (Press [Enter] to choose 512MB): " if ($SRAM -eq ""){$SRAM=512MB} ; if ($SRAM -eq $NULL){$SRAM=512MB} $SRV1VHD = Read-Host "Enter the size of the Virtual Machine Hard Drive (Press [Enter] to choose 40GB): " if ($SRV1VHD -eq ""){$SRV1VHD=40GB} ; if ($SRV1VHD -eq $NULL){$SRV1VHD=40GB} $VMLOC = Read-Host "Enter the location of the Virtual Machine file (Press [Enter] to choose C:\HyperV): " if ($VMLOC -eq ""){$VMLOC="C:\HyperV"} ; if ($VMLOC -eq $NULL){$VMLOC="C:\HyperV"} $Network1 = Read-Host "Enter the name of the Virtual Machine Network (Press [Enter] to choose Network1): " if ($Network1 -eq ""){$Network1="Network1"} ; if ($Network1 -eq $NULL){$Network1="Network1"} # Configure Hyper-V Virtual Network remove-vmswitch $Network1 -force -erroractionsilentlycontinue new-vmprivateswitch $Network1 # Create Virtual Machines MD $VMLoc -erroractionsilentlycontinue new-vm $SRV1 -path $VMLoc new-vhd -vhdpaths $VMLoc\$SRV1 -size $SRV1VHD add-vmdisk -vm $SRV1 -controllerid 0 -lun 0 -path $VMLoc\$SRV1 get-vm $SRV1 | add-vmdrive -controllerid 1 -lun 0 -dvd get-vm $SRV1 | set-vmmemory -memory $SRAM get-vm $SRV1 | add-vmnic -virtualswitch $Network1

Thursday, July 10, 2014

Monitor Scheduled Tasks with SCOM

Progel Windows Scheduled Tasks Management Pack for System Center Operations Manager


Progel has made the management pack available to the community for free that can monitor Scheduled Tasks on Windows Servers. It supports versions 2000, 2003, 2008, 2012, and 2012 R2. The Progel Windows Scheduled Tasks management packs monitor the performance, health, and availability of scheduled tasks.


Wednesday, July 2, 2014

SSRS Report Manager URL Error “HTTP Error 503. The service is unavailable”

This error is usually caused by SQL Server's Reporting Services sharing either the same port number. In order to resolve this issue please do the following:

  1. Click Start --> All Programs --> SQL Server 200* --> Configuration Tools --> Reporting Services Configuration Manager
  2. If stopped, click Start on the Report Server.
  3. Click on Report Manager URL, and then click the Advanced button.
  4. Select the current IP address for Report Manager then click Edit.
  5. Change the TCP Port to an available port number that other SSRS services are not running on, then click OK.
  6. Click OK, and then Exit.

Friday, June 20, 2014

Powershell Script to add user to "Allow Logon Locally" policy

##

$accountToAdd = "Domainname\Username"




##

$sidstr = $null
try {
$ntprincipal = new-object System.Security.Principal.NTAccount "$accountToAdd"
$sid = $ntprincipal.Translate([System.Security.Principal.SecurityIdentifier])
$sidstr = $sid.Value.ToString()
} catch {
$sidstr = $null


}
Write-Host "Account: $($accountToAdd)" -ForegroundColor DarkCyan

if( [string]::IsNullOrEmpty($sidstr) ) {
Write-Host "Account not found!" -ForegroundColor Red
exit -1


}
Write-Host "Account SID: $($sidstr)" -ForegroundColor DarkCyan

$tmp = [System.IO.Path]::GetTempFileName()

Write-Host "Export current Local Security Policy" -ForegroundColor DarkCyan
secedit.exe /export /cfg "$($tmp)"

$c = Get-Content -Path $tmp

$currentSetting = ""

foreach($s in $c) {
if( $s -like "SeInteractiveLogonRight*") {
$x = $s.split("=",[System.StringSplitOptions]::RemoveEmptyEntries)
$currentSetting = $x[1].Trim()



}

}
if( $currentSetting -notlike "*$($sidstr)*" ) {
Write-Host "Modify Setting ""Allow Logon Locally""" -ForegroundColor DarkCyan



if( [string]::IsNullOrEmpty($currentSetting) ) {
$currentSetting = "*$($sidstr)"
} else {
$currentSetting = "*$($sidstr),$($currentSetting)"


}


Write-Host "$currentSetting"



$outfile = @"




[Unicode]

Unicode=yes

[Version]

signature="`$CHICAGO`$"

Revision=1

[Privilege Rights]
SeInteractiveLogonRight = $($currentSetting)



"@

$tmp2 = [System.IO.Path]::GetTempFileName()






Write-Host "Import new settings to Local Security Policy" -ForegroundColor DarkCyan
$outfile | Set-Content -Path $tmp2 -Encoding Unicode -Force

#notepad.exe $tmp2
Push-Location (Split-Path $tmp2)




try {
secedit.exe /configure /db "secedit.sdb" /cfg "$($tmp2)" /areas USER_RIGHTS
#write-host "secedit.exe /configure /db ""secedit.sdb"" /cfg ""$($tmp2)"" /areas USER_RIGHTS "
} finally {
Pop-Location


}
} else {
Write-Host "NO ACTIONS REQUIRED! Account already in ""Allow Logon Locally""" -ForegroundColor DarkCyan


}
Write-Host "Done." -ForegroundColor DarkCyan