Skip to main content

Posts

Showing posts from January, 2015

In Windows 7, how to create a route for a dial up PPTP VPN in powershell

# # VPN Route Fixer $VPNName = "VPN Name" $NetToRoute = "172.x.x.0/x" #----------------------------------------------------------- # Dial the VPN Connection rasdial $VPNName # Get the IP Address of the VPN Connection $vpnObj = Get-WmiObject -Namespace 'root/standardcimv2'        MSFT_NetIPaddress |        Where-Object { $_.InterfaceAlias -eq $VPNName } |        Select IPAddress $vpnIP = $vpnObj.IPAddress route add $NetToRoute mask 255.255.255.0 $vpnIP

Powershell not returning same memory use as Task Manager

Task Manager gets that information from a performance counter, which is not directly available from the information returned by Get-Process.  You can get to the information with PowerShell, though.  This example uses the Get-Counter cmdlet, which is new to PowerShell 4.0 (though you can use the underlying .NET classes to accomplish something similar in older versions of PowerShell, if needed.) Get-Process |  ForEach-Object {  $proc = $_  $counter = Get-Counter -Counter "\Process($($proc.Name))\Working Set - Private"  $pws = 'Unknown'  if ($null -ne $counter)  {    $pws = $counter.CounterSamples[0].CookedValue  }  $proc | Add-Member -NotePropertyName 'PrivateWorkingSetSize' -NotePropertyValue $pws -PassThru  } | Format-Table ProcessName,Id,PrivateWorkingSetSize This method is not fast. From: https://social.technet.microsoft.com/Forums/windowsserver/en-US/46665ab7-0a22-41b5-968c-b3942e9b4a4c/getprocess-differs-from-task-manager-in-memo

Fixing up OneDrive Personal on Windows 8.1 after forensit profile migration

I migrated my profile to a domain profile using the forensit migration tool My onedrive location sits on another drive, this may explain why it didn't work, maybe, maybe not. Using Windows 8.1 Pro After the migration, I could no longer use Personal OneDrive.  The trick is the SID pointer to the OneDrive location.   This is held in the registry at  [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\SkyDrive\UserSyncRoots] The "Name" will be your SID, the data will be where your local copy of one drive resides.  To get your SID, fire up powershell and enter the following.  You are looking for your domain account.  Make note of your SID. Get-WmiObject win32_useraccount | select Caption , SID Once you have your SID, stick that in the right location at   [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\SkyDrive\UserSyncRoots]

NMAP

It's been about 15 years since I used NMAP, I forgot how useful the tool is. To find out what services are running on an IP address simply use something like nmap -n -v -p1-10000 x.x.x.x -n tells nmap not to do name resolution (saves about 13 seconds if the IP you're scanning isn't in DNS_ -v verbose -p1-10000 says scan ports 1 to 10,000 (otherwise nmap will only scan the first 1000 ports)

Using VBScript to get a web page

I love wget on linux, but what if you wanted to do the same thing on Windows, and do it in a scripted fashion. Well, Wscript has this handy WinHttp.WinHttpRequest object whiz up something like.... Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) objHTTP.Open "GET", "http://www.xyz.net.au:8081/somefile", False objHTTP.Send Of course, you'll probably want to do something with the file, and you can with objHTTP.ResponseBody I got this from http://www.robvanderwoude.com/vbstech_internet_download.php Rob mentions an even better method that requires X-HTTP from http://www.xstandard.com/en/documentation/xhttp/

Group Policy Editor

I don't manage Group Policy enough and I always forget how to get there.  To me, it appears the most convoluted thing ever invented. Start gpmc.msc Select a node (like Default Domain Policy) and right click and then select "Edit" This will bring up an MMC with the selected node in the Group Policy Management Editor.  The last trick is to do a "gpupdate"

Correcting a Broken View in MySQL

Recently I had a problem where I renamed a db field to allow for better maintenance (the field name misrepresented it's actual use and conflicted with another use). In the process, I broke a view that used the table. MySQL then complained about "...references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" The view itself became impossible to edit.  However you can access the view definition with the following query. SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = ' database_name ' AND TABLE_NAME = ' view_name ';