SMTP Port 25

Anything and Everything Related to Messaging and Collaboration, Active Directory and Scripting. It’s My Life!!!

Archive for March, 2010

Managing Windows 2008 Schedule tasks from Commandline

Posted by Krishna - MVP on March 29, 2010

SCHTASKS helps manage Schedule Tasks from command line. Below link has the details on how to configure Schedule Tasks from command line

http://www.robvanderwoude.com/schtasks.php

Posted in Windows 2008 | Tagged: , , | Leave a Comment »

Powershell to Delete log from the remote Computer Share folder

Posted by Krishna - MVP on March 25, 2010

Below powershell helps to delete log from the remote computer which is older than specific date

$Now = Get-Date
$days = 1
$TargetFolder = "\\servername\Directory1"
$LastWrite = $Now.AddDays(-$days)
$Files = get-childitem $TargetFolder -include *.Log -recurse |Where {$_.LastWriteTime -le "$LastWrite"}
Remove-Item $File

Posted in Powershell | Tagged: , , | Leave a Comment »

Powershell to get list of Exchange Storage Group if Circular logging is enabled

Posted by Krishna - MVP on March 25, 2010

Powershell command to get list of storage groups which has  Circularlogging enabled

Get-StorageGroup |?{$_.CircularLoggingEnabled -eq $True}| select server,AdminDisplayName,CircularLoggingEnabled

Posted in Exchange 2007, Powershell | Tagged: , , | Leave a Comment »

VB Script to Modify Folder NTFS Security and Share Permission

Posted by Krishna - MVP on March 25, 2010

Below is the VBscript to Modify Folder NTFS Security and Share permission. It is using Cacls.exe and Rmtshare.exe to modify the permission. Cacls.exe can be used to modify Folder NTFS security Permission and  rmtshare.exe modifies Share Permission.  Below script removes all the existing permission NTFS Permission and Provides domain\accountname Full access and remove Inheritance check box and provide domain\accountname read share permission and remove all the other share permission. You can modify the script to suite your requirement

Set WshNetwork = WScript.CreateObject(“WScript.Network”)
strFolderName = Installerpath(WshNetwork.ComputerName)
Set objShell = CreateObject(“Wscript.Shell”)
intRunError = objShell.Run(“%COMSPEC% /c Echo Y| cacls ” & strFolderName & ” /c /g domain\accountname:F”, 2, True)
intRunError = objShell.Run(“F:\Krishna\Rmtshare.exe \\Servername\Sharename /remove”)
intRunError = objShell.Run(“F:\Krishna\Rmtshare.exe \\Servername\Sharename /grant “”domain\accountname”":read”)
intRunError = objShell.Run(“F:\Krishna\Rmtshare.exe \\Servername\Sharename /remove everyone”)

Function Installerpath(compname)
strPath = “\\” &  compname & “\Sharename”
strPath = Replace(strPath, “\\”, “”)
arrPath = Split(strPath, “\”)
strComputer = arrPath(0)
strShare = arrPath(1)
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″)
Set colItems = objWMIService.ExecQuery(“Select * From Win32_Share Where Name = ‘” & strShare & “‘”)

For Each objItem in colItems
strFolderName = objItem.Path
Next
Installerpath = strFolderName

End Function

Executing the script :

Save the file as .vbs and you can execute locally or user psexec.exe to execute script remotely. Below is the psexec command to run remotely.

Psexec.exe \\servername cscript C:\Securitymodify.vbs

You can find the copy of the code in the below link

http://powershell.com/cs/members/smtpport25.wordpress/files/ModifySecuritySharePermission.txt.aspx

Posted in VB Scripts | Tagged: , , , | Leave a Comment »

Powershell to check check user Security Permission using Dscals

Posted by Krishna - MVP on March 18, 2010

Powershell to check if  set of users for security security permission. Below script helps to check if users has Account Operators listed in security permission

$csv = Import-csv -path "D:\Krishna\dsacls\user.csv"
foreach($line in $csv)
{
$input = "\\Servername\" + $line.DN
$K = .\dsacls.exe $input
$i = 1
foreach ($service in $K)
{
$Status = $service -like "Allow BUILTIN\Account Operators*"
if ($status -eq $true)
{
i= 0
}
}
if($i -eq 1)
{
$line.mailnickname >> dcalsresult.txt
}

You can also find the copy in the below link

http://powershell.com/cs/members/smtpport25.wordpress/files/UserSecurityPermission.ps1.aspx

Posted in Powershell | Tagged: , | Leave a Comment »

Powershell 1.0 to check DHCP Client Service Status on All Set of Computers

Posted by Krishna - MVP on March 12, 2010

$servers=get-content c:\servers.txt
$services=”dhcp”
foreach($server in $servers){
$result=gwmi -computer $server win32_service
foreach($service in $services){
$result|where{$_.name -eq $service} | Select name, state
}
}

Posted in Powershell | Tagged: , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 49 other followers