PowerShell List Files Changed in the Last 7 Days

$startingpath=”C:\”

$startingdate=$(Get-Date).AddDays(-7)

Get-Childitem $startingpath -Recurse | where-object {!($_.psiscontainer)} | where { $_.LastWriteTime -gt $startingdate } |  foreach {  Write-Host “$($_.LastWriteTime) :: $($_.Fullname) ”  }

# OR #

foreach {Write-Output “$($_.LastWriteTime) :: $($_.Fullname) ” >> changedfiles.csv }

Advertisements

PowerShell Edit Registry to FlipFlopWheel (Mouse Natural Scrolling)

# View all registry entries with FlipFlopWheel

Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0

# Change the registry settings for each entry with FlipFlopWheel
# Reverse mouse wheel scroll FlipFlopWheel = 1
# Normal mouse wheel scroll FlipFlopWheel = 0

Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }

C# DateTime as a String

Working with DateTime to produce a usable date string ie: 2003-03-08 21:17:42

public String GetDateTimeString(DateTime dt)
{
StringBuilder sb = new StringBuilder();
sb.Append(dt.Year);
sb.Append(“-“);
if(dt.Month < 10)
sb.Append(“0”);
sb.Append(dt.Month);
sb.Append(“-“);
if(dt.Day < 10)
sb.Append(“0″);
sb.Append(dt.Day);
sb.Append(” “);
if(dt.Hour < 10)
sb.Append(“0”);
sb.Append(dt.Hour);
sb.Append(“:”);
if(dt.Minute < 10)
sb.Append(“0”);
sb.Append(dt.Minute);
sb.Append(“:”);
if(dt.Second < 10)
sb.Append(“0”);
sb.Append(dt.Second);
return sb.ToString();
}

Call with String xx = GetDateTimeString(DateTime.Now);

Rights Needed to Install SQL Server Developer Edition on Your Machine in a Secure Environment

ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeDebugPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeCreateTokenPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeServiceLogonRight
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeImpersonatePrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeInteractiveLogonRight
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeAssignPrimaryTokenPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeChangeNotifyPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeIncreaseQuotaPrivilege