Wednesday, February 25, 2015

Using PSEXEC to execute powershell scripts remotely

I ran into an issue where I found myself having to hit the any key to complete a psexec call to a batch file that launches powershell. The workaround was to add -inputformat none to my launch parameters for powershell.

example: powershell -inputformat none -file C:\scripts\StampBackups.ps1 -executionpolicy bypass 

ref http://stackoverflow.com/questions/4238192/running-powershell-from-msdeploy-runcommand-does-not-exit/4239192#4239192

ref https://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected

Monday, February 9, 2015

Migrate tons of groups and users

So I had to create a bunch of local groups and populate them with accounts from active directory as determined by a query on the server I was migrating from. There was probably a hundred groups defined, with tons of users in each. 2 scripts to get this done, sure I could spend more time to consolidate into one but time was of the essence. Please test, I'm not responsible for your environment. Script 1. I used this to collect the info. I found this out on the web, I forgot who created it otherwise I'd give them credit. I did modify it further suit my needs. Trap {"Error: $_"; Break;} Function EnumLocalGroup($LocalGroup) { $Group = [ADSI]"WinNT://$strComputer/$LocalGroup,group" "Group: $LocalGroup" # Invoke the Members method and convert to an array of member objects. if (($LocalGroup -ne "HelpServicesGroup" -or $localgroup -ne "Guests")){ $Members= @($Group.psbase.Invoke("Members")) $Collection = @() ForEach ($Member In $Members) { $path = $Member.GetType().InvokeMember("Parent", 'GetProperty', $Null, $Member, $Null) $Name = $Member.GetType().InvokeMember("Name", 'GetProperty', $Null, $Member, $Null) $collection += "$LocalGroup;$path/$Name" } $collection|Out-File -FilePath $filepath -Append } } # Specify the computer. $strComputer = (Read-Host "What Computer") "Computer: $strComputer" #specify the file path $filepath = (Read-Host "File path to export results to" $computer = [adsi]"WinNT://$strComputer" $objCount = ($computer.psbase.children | measure-object).count $i=0 foreach($adsiObj in $computer.psbase.children) { switch -regex($adsiObj.psbase.SchemaClassName) { "group" { $group = $adsiObj.name EnumLocalGroup $group } } #end switch $i++ } #end foreach Script 2. Reads CSV and breaks it out $PATH = (read-host "Please type the file path to your semi-colon delimited file") $groupsNusers = Import-Csv -Path $PATH -Delimiter ';' $remotecomputer = (read-host "Please enter the computername"") foreach ($strCollection in ($groupsNusers)){ $localgroup = $strCollection.group $aduser=$strCollection.user.ToString().Replace("\","/") try { $user = [ADSI]("WinNT://$aduser") $New = [ADSI]"WinNT://$remotecomputer" #create groups $NEWgroup = $NEW.Create("Group","$LocalGroup") $NEWgroup.setinfo() $objGroup = [ADSI]"WinNT://$remotecomputer/$LocalGroup,group" $objGroup.PSBase.Invoke("Add",$User.PSBase.Path) } Catch [System.Management.Automation.MethodInvocationException] { if ($_.Exception.HResult -eq "-2146233087") {write-host "$aduser is already in $localgroup";continue} else {Write-Error "Unhandled error:" + $_.exception;Break} } Catch {Write-Error $_} } $PATH = "" $groupsNusers = "" $aduser="" $localgroup=""

Sunday, October 12, 2014

Bucky Brown

Wednesday, December 11, 2013

AxInstSV

Problem: AxInstSV Failed to Read Description. Error Code: 15100 Create a reg file with this information: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\83\52C64B7E] "@%SystemRoot%\\system32\\AxInstSV.dll,-104"="Provides User Account Control validation for the installation of ActiveX controls from the Internet and enables management of ActiveX control installation based on Group Policy settings. This service is started on demand and if disabled the installation of ActiveX controls will behave according to default browser settings." [HKEY_CLASSES_ROOT\Local Settings\MuiCache\15\52C64B7E] "@%SystemRoot%\\system32\\AxInstSV.dll,-104"="Provides User Account Control validation for the installation of ActiveX controls from the Internet and enables management of ActiveX control installation based on Group Policy settings. This service is started on demand and if disabled the installation of ActiveX controls will behave according to default browser settings." [HKEY_CLASSES_ROOT\Local Settings\MuiCache\83\52C64B7E] "@%SystemRoot%\\system32\\AxInstSV.dll,-104"="Provides User Account Control validation for the installation of ActiveX controls from the Internet and enables management of ActiveX control installation based on Group Policy settings. This service is started on demand and if disabled the installation of ActiveX controls will behave according to default browser settings."

Saturday, October 12, 2013

awesome book

Saturday, February 23, 2013

Why I dislike printer drivers in Windows

I'd be battling a crazy case of the mstsc dumps.  Basically what happens is this; I'll remote to a server, and just as i'm getting started MSTSC (RDP)  crashes.  Frustrated as this just started happening no, major changes that should affect the rdp systems. I'm running windows 8 enterprise

it happened just about everytime to a windows 2008r2 box, or through Remote Desktop services.  I scoured Microsoft's new "Support site"  which is a slap in the face to people who've relied on being able to us it but i digress.

So I started up windows debugger, and I had to be quick about it since the main pain was through rds (use F6).  Thanks for split screens.  I was able to attach to mstsc.exe quick enough to catch the first break point. So i continued from that point till the actual crash. which led me to a dell throwing a c0000005 access denied message.  The DLL was dlxbujdm.dll which I traced back to a Dell printer driver...  I really don't like Dell printers.

It was my default printer and never had a problem before, so what happened???  I haven't a clue,  But I removed the printer driver and package, rebooted and no more crashes.  If you get a failure in removing, reboot and try removing again.  I think you'll find it'll work that time.

hope this helps someone else from a headache.