Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Thursday, January 12, 2012

Operation is not valid due to the current state of the object.

I was working on this PowerShell script, pulling DHCP scopes and their registered entries, DNS forward and reverse lookup records, and deleting them based on scpecific criteria. The script cleans DNS by checking agains DHCP records and any DNS record not found in the list for each scope gets deleted, same goes for expired, or with a different "OwnerName". This was needed because anomalities in DNS entries for supposedly static records kept us from turning on scavenging without removing some servers. We thought this was best way to filter them out.

There I am, going crazy with powershell, creating a complicated script, getting WMI objects and filtering per our needs. Using hashtables of hashtables, hashtables of arrays of objects, calling functions to check against other objects or lists. Then after a few days of coding and searching online how to best do it, right when I tried to delete one record as a test:
Exception calling "Delete" with "0" argument(s): "Operation is not valid due to the current state of the object."
At line:1 char:22
+ $result | %{$_.Delete <<<< ()}
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
What!? Don't tell me I cant delete them now! Why?
I went searching for that error, looked at several howtos, tutorials, forumns, etc. Nothing mentioned seemed to be the problem I was having. Eventually through trial and error I figured it out.
I had this code:
Get-WMIObject -Computer $Server -Namespace "root\MicrosoftDNS" -Class "MicrosoftDNS_AType" `
 -Filter "ContainerName='$($Domain)' AND OwnerName<>'$($Domain)'" `
 -Property @("OwnerName", "IPAddress", "Timestamp")
In oder to delete the record or modify it, you need to have the "FULL" object. The fix was to remove the property selection code, so I ended up with:
Get-WMIObject -Computer $Server -Namespace "root\MicrosoftDNS" -Class "MicrosoftDNS_AType" `
 -Filter "ContainerName='$($Domain)' AND OwnerName<>'$($Domain)'"
That worked.

Another thing to watch out for is that for whatever reason the above filtering commands wont work if you use "like, is, not, etc." in your "-Filter" property.

Happy PShelling!

Marlon

Tuesday, August 9, 2011

How to fix "FontConfig <cachedir>" errors...

If you are getting "FontConfig <cachedir>" errors every time you run a program or in your Xorg.0.log file similar to the following:

Fontconfig warning: no  elements found. Check configuration.
Fontconfig warning: adding /var/cache/fontconfig
Fontconfig warning: adding ~/.fontconfig

This is a simple fix...in fact it's telling you what to do in the warning text. The last two lines mention that you need to add those xml elements into your .fonts.conf file. It's erroring out because it doesn't really add them by itself but you can simply add them manually or run:

sed '
/<\/dir>$/{
N
s%\(</dir>\)\n*\(\s*<match\)%\1\n <cachedir>/var/cache/fontconfig</cachedir>\n <cachedir>~/\.fontconfig</cachedir>\n\2%
}' .fonts.conf

Tuesday, April 12, 2011

Using "find" to execute a command on files or folders...

The other day I was trying to make all the folders under a directory available for traversing for the owner group (chmod g+rx) but I couldn't get "find" with the "-exec" switch to work. I had installed Eclipse manually and since my umask is 077 it was not letting me access it since root was the owner. I changed the owner group to users and added +r for the group on all files but of course that is not enough for folders. I figured I would use find to get me all the folders and use -exec switch to change the permissions. So I had:

sudo find -type d -exec chmod go+rx '{}'\;

which kept giving me an error message:

find: missing argument to `-exec'

What?! I have all the right arguments, I read the man pages, looked online, tried info looking for samples. It was all there...well not quite, it seems you need to make sure there is a space between the last tick mark (') and the backslash (\).i.e.:

sudo find -type d -exec chmod go+rx '{}' \;

Wednesday, October 27, 2010

Citrix client on Ubuntu 64 bit versions.

Installing the client seems to be a breeze after downloading from the Citrix website. The problem is it wont run unless you install the x86 version of OpenMotif.  It also requests libXm.so.4 instead of the installed libXm.so.3 library. Every time I have to do it I need to search how since I forget but there are so many hits that I just cant seem to find the one with all the steps. I have decided to post it here to make it easy on myself. Hopefully it will you as well.

  1. Make sure you already have the ia32-libs libraries installed since they are required by 32 bit programs running on 64 bit linux.  They probably are, but just in case...
    sudo apt-get install ia32-libs
    

  2. Download the linux x86 client of your choice from Citrix and install it (I used the tar.gz file), after you extract it to a folder run:
    sudo ./setupwfc
    

  3. Once that's done you can check if it doesn't run with the following command:
    /usr/lib/ICAClient/wfcmgr -icaroot /usr/lib/ICAClient
    
    Note:
    It should be requesting "libXm.so.4" and if it was a 64 bit application you could install OpenMotif like so:
    sudo apt-get install libmotif4
    
    ...but it wont have a 32 bit version in it and the client is a 32 bit application which wont use a 64 bit library.

  4. Create a temp folder and go to it in the console, once there run the following commands:
    wget http://archive.ubuntu.com/ubuntu/pool/multiverse/o/openmotif/libmotif4_2.3.3-5ubuntu1_i386.deb
    dpkg -x libmotif4_2.3.3-5ubuntu1_i386.deb ./libmotif/
    sudo mv ./libmotif/usr/lib/* /usr/lib32/
    sudo chown -R root: /usr/lib32/*
    rm libmotif3_2.2.3-4_i386.deb
    rm -rf ./libmotif/
    

  5. You should now be able to either click on the icon from the applications menu or you could simply run the first command in step 3.
Note:
If you are not running an Ubuntu (Kubuntu, Xubuntu, etc.) distro just make sure to replace the wget command with the right url to your distro's archive.
Enjoy and happy linuxing,

Marlon