I was building a more involved function the past couple of days for gathering data from a PC in the enterprise should troubleshooting be necessary. The type of company I work for doesn’t always allow us to stay on the PC and troubleshoot an item (unless it’s a total blocker) so being able to gather a broad range of data is necessary to really troubleshoot since we can’t be on the machine. Part of that function is retrieving hard drive information. I’m only gathering a few pieces of info, but since PC’s can have multiple drives I needed a good way to manage each disk separately. I could have done it with the following line of code, but as you can see from the screenshot, it’s messy and the numbers output are in bytes which isn’t useful at first glance.
gwmi -class win32_logicaldisk | Where {$_.DriveType -eq 3 -OR $_.DriveType -eq 4} | select -property DeviceID,Size,FreeSpace
The big thing is to convert those numbers into something more meaningful. I also don’t like the clumped output and wanted to be able to handle each disk separately and call any of it’s properties without additional formatting (to see what I mean, run that code and then try pulling just $var.DeviceID and you’ll see all the hashtable @ and{} characters… it’s a mess). I decided to create the hashtable myself. Since there could be multiple disks I also needed it to really be more like an object. That’s where nesting my hashtables came in. My other requirement, dynamically creating variables, comes from wanting to return all of my unknown-beforehand-number-of-disks within the same variable, but needing a way to make unique hashtable key names ($return.Disk1… , $return.Disk2… , etc). It sounds confusing, so here’s the code:
Function getHD($strComputer) { # Retrieves hard drive information $return = @{} # declare our return variable as a hashtable so it doesn't get created as a string $i = 0 # counter and dynamic part of variable for disks $hd = gwmi -comp $strComputer -class win32_logicaldisk ForEach ($disk in $hd) { If ($disk.Drivetype -eq 3 -OR $disk.DriveType -eq 4) { # only return physical hard drive and network drive types (5 is CD) $i++ $return.numDrives = $i # where I store the number of drives found so I can use that to iterate through them all later $return += @{ "Disk$i" = @{ # new hashname must be in quotes so variable will be expanded DriveLetter = $disk.DeviceID Size = $disk.Size/1048576 # Convert to MB FreeSpace = $disk.FreeSpace/1048576 # Convert to MB } } } } return $return }
So now what? I call my function by: $hdinfo = getHD $pc Then I run through that returned hashtable “object” and output the data to a file. That is just a few simple lines:
For ($i=1; $i -le $hdInfo.numDrives;$i++) { $hdvar = "`$hdinfo.disk$i" invoke-expression $hdvar | Out-file $global:consolePath\PCData\$pc\PCVitals.txt -append -noclobber }
And what does it all look like?
Name Value ---- ----- FreeSpace 1171586.5703125 DriveLetter C: Size 1437513.9921875 Name Value ---- ----- FreeSpace 1143174.359375 DriveLetter D: Size 1423843.99609375 Name Value ---- ----- FreeSpace 1034453.83984375 DriveLetter E: Size 1430727.99609375
I could do a little more formatting if I wanted, but this is good enough for me! And if I wanted to further use that data in a function it’s easy to reference an individual item with just $hdinfo.Disk1.FreeSpace or $hdinfo.Disk2.Size
I need to vent a little before I get into the code. Had a frustrating one today! All because of unclear documentation in MSDN’s published library of their .NET classes. I guess it’s true what they say, that sometimes you should listen to what isn’t said.
I had to build a work-around to a problem with an MSI from a certain cardiovascular imaging software. It seems the MSI wants to strip the permissions for the local “Users” group off of the C:\ProgramData folder. Not cool! At first the vendor tried to brush it under the rug and gave me a few lines about the development process, blah, blah (develoment?! you’re just fixing the installer!) and then said it could take 10-12 weeks (which is further out than our very-rushed go-live) and if I could just work around it. Did I mention this isn’t a lesson in customer service skills?
So anyway, I sat down to figure out how I was going to do it. I’ve lost a lot of my VB skill because I haven’t used it in over 6 months and I’ve been learning a lot of Powershell. I love Powershell and I’ve already written code to modify permissions (on a file on XP) so I figured this would be easy. The one good thing I had going is the issue is only affecting Windows 7 so running the Powershell script locally isn’t a problem (we never pushed PS out to our XP devices). What I thought would be a 5 minute mod of my existing code turned out to be about 30-40 minutes.
It seems just supplying the user/group (IdentityReference), read/write/etc (FileSystemRights), and Allow/Deny (AccessControlType) were enough… but not really. Mine was set to:
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("Users","ReadAndExecute","Allow")
When setting just those three properties the permissions got applied but if you right-clicked on the folder and viewed the Security tab of the folders properties you saw a blank list of rights for that user/group. All except for “Special Permissions” at the bottom. If you went into advanced and dug a little deeper you could see that the Traverse folder/ execute file, List folder/read data, Read attributes, and Read extended attributes were all selected. Read permissions was not. Kind of a problem. Below is what that looked like.
The other problem is it says “Apply to: Subfolders and files only”. With the changes not applying to the root folder I actually made the changes on, and not having proper read permissions, I have a funky looking ACL. The odd thing is that the permissions I was wanting to apply worked. Someone who fell into the “Users” group was able to read and execute like I wanted. But, it’s technically broken so it needed to be fixed.
So I called up the MSDN library to find out what else I might need. This post is already longer than it needs to be so it will suffice to say that I fiddled around with the InheritanceFlags Enumeration and PropagationFlags Enumeration parameters for quite a while. I assumed the the FileSystemRights could be comma-separated since there were many options and you could have multiple. I tried that and it worked, I got the “Read Permissions” checkbox back on the advanced properties view. Still, the ACL was blank on the Security tab (with the exception of Special Permissions). that took setting the Inheritance and Propagation flags correctly. Both of these flags apply ONLY to the child object. They do not affect whether the folder you are making changes to will inherit from it’s parent. Inherit determinse whether the child object(s) inherit from the folder you are making changes on and propagate is what it pushes them down to. Propagate is dependent on Inherit.
Ok, finish this up already. Since I needed to put permisions back to default so that All Users/Public can appropriately access that folder I needed both file and folders to inherit. And the kicker (reading what isn’t said…) is that the Propagation flags have to be set to None. Why? Because it doesn’t mean it wont propagate, it means it’s going to use the default value for propagation, which is: This folder, subfolders, and files! But the documentation does not say that anywhere! It finally dawned on me that, that is what it would do. So, my final code for adding “Users” to the ACL for the C:\ProgramData folder with Read and execute, List folder contents, and Read permissions is:
$Acl = Get-Acl C:\ProgramData $Ar = New-Object system.security.accesscontrol.filesystemaccessrule("Users","ReadAndExecute,Read","ObjectInherit,ContainerInherit","None","Allow") $Acl.SetAccessRule($Ar) Set-Acl C:\ProgramData $Acl
Line 1 I’m getting the ACL of the object I want to modify
Line 2 I’m creating a new access rule and setting all of the parameters. The local Users group, the TWO FileSystemRights, the Inheritance Flags (so that folders and files inherit), the Propagation flag (none means use default), and finally that I”m Allowing access and not Denying.
Line 3 I’m taking that access rule and adding it to the ACL object I created from the folder
Line 4 I’m actually setting the new ACL [in stone]
Yes, all that for 4 lines of code.
“Special” thanks to the MSDN library: http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx
Bleh! I’ve been so busy with the new position I started in April I’ve fallen off posting on this blog. I have a lot of Powershell stuff I want to post—creating progress/activity bars, hashing, and perhaps a series on creating a simple text console. I’ve also not been paying attention to replies, sorry! I get so much spam from this blog that Gmail started dumping all my email alerts to comments in my spam box, which I never check. I did respond to a couple, though… and realized I REALLY need to build-out the styling of the reply section and add the functionality to reply to comments!
Anyway, I just wanted to drop this quick and easy one here that I had to figure out last night. I tried googling a solution for batch conversion last night when I needed to convert about 40 flv’s to mp4. The web yielded nothing too great. One site had a Powershell script but it didn’t work. So, I just took from it what parameters I had to pass to the VLC application and wrote my own script.
This script has to be run from the directory where the videos are and it outputs them to the same directory. I’m using Powershell 2.0 on Windows 7 Ultimate with VLC 2.0.4
$fileItems = Get-childitem -filter *.flv
ForEach ($file in $fileItems) {
$destination = “$($file.fullname).mp4”
start-process “C:\Program Files (x86)\VideoLAN\VLC\vlc.exe” “-I dummy -vvv “”$($file.fullname)”” `
–sout=#transcode{vcodec=h264,vb=1024,acodec=mpga,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=””$destination””} vlc://quit” -wait
}
The parts:
Hope this saves someone some time 🙂
Realized I still haven’t posted about the specs of the new PC I built back in mid May. So here’s a quick post to get that out:
CPU: Intel Core i7-3770K Ivy Bridge 3.5GHz
MB: ASUS P8Z77-V Deluxe
Graphics: NVidia GeForce GTX 560 Ti FPB (EVGA, 1GB of 256bit DDR5)
HD: 2 x Seagate Barracuda 3TB, 7200 RPM (ST3000DM001)
RAM: 16GB of GSkill Ripjaw X series DDR3 1600 (2 x 8GB)
Power: Corsair 650TX
Optical: Asus DVD-R/W drive (DRW-24B1ST, Black)
Case: Thermaltake Chaser MK-I
I haven’t really put it to the test yet, although it plays WoW just fine. Occasionally I have some chop but I’m not sure if it’s my PC. The Witcher plays nicely, haven’t noticed any chop in that unless I have the graphics cranked way up, which shouldn’t be. I should put Crysis on it soon and see how it does at full graphics.
With HT I love the fact that I have “8” cores. All the RAM is nice, too. I have an Ubuntu Server running right now that I’m setting my own personal WoW server up on and Wrath of the Lich King is installing on another VM that’s running. All the while not bogging down my desktop! PC runs fairly cool, idles at 37C (with stock cooler). With WoW running I think it’s in the mid to upper 40’s. Max safe operating temp is 67.4C so I have plenty of room. The other thing that is completely amazing is that the fans are so quiet I honestly don’t even know it’s on. The first morning I got up after having powered off the old machine I had to check to make sure the new one was on it, it’s dead silent. Even if I sit here and focus on the machine and try to hear something I dont… unless I turn the chasis fans up to high then all I hear is the gentlest white noise.
Apps load pretty quick (Outlook 2010 is about 10 seconds.. iTunes, FF and others are almost instant). Overall I’m pretty darn pleased!
My nostalgia for old computer software/equipment put a bug in my head to get the old Win98 screensavers. Specifically, “Mystery.” I was greatly disappointed by the fact that Win98 native didn’t support more than 16 colors and a 640×480 resolution (I was further disppointed by the fact that Win7 can’t run the old screensavers! Ugh!).
I kept googling for generic drivers that would allow me to up my color and resolution. I finally found the “bear” drivers for windows. I hard tried SciTech Display Doctor but I couldn’t get it to work properly. It either didn’t let me boost the color to what it should be or caused the entire VM to lock up after I booted into it. Not to mention, it’s only a trial! The problem is the driver wont work (right) with the un-patched install from the CD. MS doesn’t support the OS so you can’t update from their site, either. Luckily, there is a kind fellow who has provided a “Service Pack” of updates for the OS and has made it available for DL. Below are the steps to go through to get your Win98 patched, video quality improved, and sound working.
If you’re having trouble getting these files onto the Win98 VM (since it doesn’t support Guest Additions and therefore no folder sharing with the host) you have a few options. You can burn a CD or use an FTP program like I did. I have my own domain (duh!) so I uploaded the files there. CoreFTP has a fairly navigable web page and it has a version that supports Win98, oh and it’s free! When you go to download the page renders pretty bad from whatever file service they use but it’s manageable.
Info on getting your sound to work (selecting Soundblaster 16 in the Audio config for the VM) can be found here: https://forums.virtualbox.org/viewtopic.php?t=9918
Huge thanks to the folks at the places above for putting these things together!
So I built a new PC this week! I’ll post more about that later, for now I want to document how I got booting the Windows 7 install in UEFI working so that I can take advantage of my whole 3TB drive and not just 2TB of it!
The UEFI “BIOS” comes pre-config’d for UEFI so I didn’t think I needed to do anything. I installed windows by all the defaults in the wizard. Then I realized that 764GB of my drive was unallocated and it wouldn’t let me create a partition! I know I had read that Windows 7 supported the larger drives so I hopped on the net to try and figure out what was going on. Turns out you have to explicity boot UEFI so I hopped into the setup utility to configure that. For those of you who had already installed Windows, there will be an extra few steps to convert the drive.
I was getting frustrated after reading MS’s article about converting the drive. No where in the ASUS manual (or that I could find online) talked about what explicitly to do to make sure you were booting UEFI. Thankfully I found the sites below to make the rest of my process easier after figuring that stuff out.
http://support.microsoft.com/kb/2604034
http://www.sevenforums.com/tutorials/186875-uefi-unified-extensible-firmware-interface-install-windows-7-a.html
UPDATE 01/30/2014
There is a registry hack in Windows 7 to enable this feature again (although I wouldn’t necessarily suggest it… MS doesn’t support it).
You can naviGate to HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2} and clear out the value for RunAs. This will enable the ability to do a runas and have explorer run in a separate process. If you don’t want to go this route, see the original post below.
In XP we have a nifty little work-around to logging in as an admin without having to log the user off the desktop. At the command line we can type:
C:\> runas /user:USERNAME@Domain “explorer /e, /separate”
Then it prompts us for our password and up pops a separate explorer shell running as our privileged account. We can then proceed to do as we need.
In Windows 7 this doesn’t work 🙁 I did a little research and Microsoft now no longer allows us to run explorer as two separate users, simultaneously. On the one hand this isn’t as much of a problem because Powershell supports UNC paths so we can get to wherever we need to go in the new shell. I’ve just started reading “Learn Windows Powershell In a Month of Lunches” and I’m liking PS a lot already. MS seems to be moving towards many of their apps working on top of Powershell (like the Exchange GUI) so it’s a good idea to learn. You can right-click on Powershell and choose “Run as Administrator” to load it as yourself. Unless you’re not comfortable with the command line (and you should be if you’re an administrator), I can’t see the need to use the explorer GUI anymore. However, I wanted to see if I could figure out how to do it…
Let’s say you don’t want to learn Powershell or you have some reason for wanting the GUI (and I’ll set my devil’s advocacy aside for a moment). I did figure out a way to do it shortly after my frustrating moment of reading about MS’s change with Explorer (I can’t complain too much though, it IS more secure), but not quite like XP. MS stopped us from running Explorer as two simultaneous users. All you have to do is kill the explorer process and then start it again as another user. Since XP, we’ve had a clean way to do this without having to completely logoff the machine or close any other processes open on the PC. Through this whole procedure, any running processes that were open as the user will stay open and running under their user context. So here’s the step-by-step:
I only did minimal testing with this shell changing. However, I didn’t notice any issues with the desktop or user context getting “messed up” because of the switching. Microsoft intentionally made the CTRL + ALT + SHIFT method for a way of cleanly exiting and restarting explorer. Desktop icons, background, folder permissions (I only checked one) were appropriate to whoever explorer was currently running as. I strongly suggest you do some testing yourself, however. If anything you’ll get more familiar with the process.
I like to give credit when I can, but the only thing I would give credit to someone else for is learning the XP command for running as another user. It’s been one of my tools for so long I can’t remember, though :\ I did a quick Google search to find something familiar and this page is definitely one I’ve been on before: http://blogs.msdn.com/b/aaron_margosis/archive/2004/07/07/175488.aspx
Edit:
I’ve had to do this again. So here is where to put the files on Ubuntu 12.04 with Citrix Receiver 13: /opt/Citrix/ICAClient/keystore/cacerts
What I did was extract the roots.zip to that folder (which you have to do in the terminal using sudo….. sudo unzip “zip file” -d /opt/Citrix/ICAClient/keystore/cacerts)
Then, since the certs need to be in the cacerts dir and not a subdir, I did this from the terminal: sudo cp /opt/Citrix/ICAClient/keystore/cacerts/VeriSign\ Root\ Certificates/Generation\ 5\ \(G5\)\ PCA/* /opt/Citrix/ICAClient/keystore/cacerts
And then I was able to launch!
Original Post:
For Receiver 12 on Ubuntu 11.10:
If you tried installing Citrix Receiver on Ubuntu 11.10 you may have run into a perpectual “SSL error 61”
There are various sites out there that tell you to to fix the issue you have to copy the cert to /user/lib/ICAClient/keystore/cacerts/ which may or may not exist on your box after installing.
I’ve found this to not work with with Ubuntu 11.10. Instead, I had to copy them to the keystore in the actual installation directory of the app. I just used the default install path of /home/MYUSER/ICAClient/. It creates the directory /home/MYUSER/ICAClient/linuxx86/keystore/cacerts and that is where you have to dump the files. Incase you’re having trouble finding the certs to download, they are here: http://www.verisign.com/support/roots.html The links for the various downloads begin after the form (which you can ignore). The very first download link below the submit button is to download ALL root and intermediate certificates.
So basically, if you are having trouble getting it working on any distro, try looking for the cert folder in your installation directory. The latest version, 12.1, I’m sure is the similar. I believe it’s default installation path is /opt/ICAClient/linuxx86 but the last time I tried to download it, the file was corrupt or the server having issues and I haven’t tried again.
So my mint-condition copy of Windows 98SE arrived today and after work I got it setup in VirtualBox. Much easier than Windows 95 (and much easier than the way many folks on the net did it). I googled it quickly to see what people ran into but figure screw it, why I don’t I just do things my usual way and find out for myself? See my previous post about Win95 to see my versions/specs that I’m running this on.
Unlike it’s predecessor, Win98 can boot off the CD and doesn’t actually need the startup disk. Once you create the HD (I chose VDI again) for it, be sure to go into Settings > System and disable hardware acceleration again like we had to for Win95 (UNCHECK “Enable VT-x/AMD-V”). If you don’t do this, you’ll receive a “Fault outside of MS-DOS Extender” error.
Then when you boot, select your CD drive with Win98 and you’ll be brought to a screen asking to boot to the local HD or the CD. Choose CD since you don’t have anything on the HD yet and it will start the dos-based setup. It’s just a few [Enter]’s and then it’s asking you to reboot to begin the GUI-based install.
Then it’s just go through the GUI wizard and do as it asks. When the file copying process finished I had to reboot. When loading for the first time and before getting to the next stage of install (setup: detecting pnp, setting date/time, etc) I got a blue screen. I remembered seeing something somewhere about turning on ACPI so I closed down the VM and turned that on (Settings > System). However, this significantly slows down response time so after I finished getting it all setup I turned this off again and it booted fine.
Once up, you dont get the internet setup Wizard like the Win95 install. When you launch IE it tries to go through a wizard to detect your modem and wont do anything else. You have to go into the control panel, open internet options, go to the connection tab, and click the setup button at the top to setup to use as a LAN. I didn’t have to fill out my gateway but it was probably because my first attempt to get the internet working without a modem was to go into my network adapter properties and configure TCP/IP with my gateway (router) IP.
And that was it, super easy. Didn’t have to create a boot iso or any kind of iso. No special storage setup. I suggest leaving it to boot to CD until you get to the desktop and setup is done. Then you can go into Settings > Storage (for the VM) and remove the CD drive.
Update 2-1-2021: I’ve added a few caveats to the instructions below while needing to run through this process again with VirtualBox version 6.1.16
It’s been much longer between my posts than I’d like. We had a re-org at work a little while back and now I’m up for another position that I’m waiting to hear on. It’s like a desktop administrator position but more.
I have a bit of a nostalgia bug and I found my old copy of Windows 95 a while back. I’ve been wanting to install it in a VM so I could play around with it again and remember old times. I made an ISO from it, mounted it, and attempted an installation. I forgot back then that CD’s weren’t bootable and I didn’t still have the boot disk. I do, however, still have my old Win98 boot disk. I think it has corrupted, however. It wouldn’t matter tho, I don’t think, as I only have an external floppy drive and the software back then didn’t support USB!
So I looked on the net and found some boot disk images. I also did a quick google search to see how complicated it was for other folks. There sure are a lot of folks that had a lot of problems! I found it to be farely simple, to be honest. I did get a few tidbits of info that helped me along in my adventure to figure it out. I’ll have several links at the end of the post. But here’s how I did it:
I’m running VirtualBox 4.1.2 r73507 on Windows 7 Ultimate, 64-bit
I have Windows 95 “A” (although the boot disk I found will work for either, I believe)
I wasn’t sure if this would work but I was easily able to get on the internet. The bad part is most pages are using code that Internet Explorer 4 can’t render. However, if the site still uses just basic HTML you should be able to render it fine.
One “old school html” page you can load to try it out is www.bootdisk.com
And that’s it!
I did a lot of trial and error trying to figure out the best way to make the ISO’s and mount. It wasn’t until I got the xcopy idea that it all became beautifully simple. But if I had looked in the first place, I would have seen xcopy was part of the downloaded boot image all along :\ It was fun though!
Here are the links where I got a few tidbits of info to help me along:
http://www.sevenforums.com/virtualization/10121-installing-windows-95-virtualbox-5.html (this is really the only one that helped me)
http://ubuntuforums.org/showthread.php?t=533611 (sort of, it pointed me in a different direction which made me realize I needed to pursue a different path)
http://www.youtube.com/watch?v=Awo948eU_eE (I tried installing DOS 7.1 first but didn’t want to mess around with mounting my drive)