I don’t normally post pictures…

Posted: 7th January 2014 by Ben in For the Technical

But this is hilarious:

ITT Tech is two ipconfig and google maps hardcore!
ITT_Hardcore

It’s true, it can’t.
So- you have to download the Vmware OVF Tool

Convert that badboy ovf to a vmx to use in Workstation!

That’s not what you wanted? Oh you are going from vmx to ovf? I’m sorry- here are both ways to do that:
(Assuming you have a environment variable to the ovftool- if not just go to the source C:\Program Files\VMware\…

conversion from vmx to ovf:
ovftool f:/somepath/os.vmx c:\temp\os.ovf

conversion from ovf to vmx:
ovftool f:/somepath/os.ovf c:\temp\os.vmx


Now you are on your way to Virtual Machine goodness!

You sometimes come up with weird desires to do things in programming and scripting and today I needed to increment my filenames not by number, but by alphabet increments. To top it off, not only alphabet entries, but two string alphabet entries! (e.g. aa, ab, ac)

So to start off we have this wonderful tidbit:

$a = 97..122 | foreach {[char]$_}


Ok so that takes care of one part of it, we have a-z and that is a perfect array.
Some of you might wonder why the hell that worked. It’s because the “..” is a range character for powershell. That means that it will print the distance of the specified. So if we didn’t convert that to a character, it would have counted 97-122 in an array (which we stored conveniently).

How did I know that the 97-122 converted to a character would be what I needed?


[int][char]'a'

And you guessed it- I did the same for ‘z’.

So now we need to allow it to count aa, ab, ac and so on and so forth. It took me a minute to logic through this, but if we just duplicate work a bit- we can let powershell do the rest.

$a = 97..122 | foreach {[char]$_}

foreach ($damnNumber in $a)
{
$item = 97..122 | foreach {[char]$_}
foreach ($damnItem in $item)
{
$damnNumber + "" + $damnItem}

Now we can apply that logic to whatever we are working on for the minute.
Hope that helps

Got an email this morning asking for help with a script! I enjoy this! Kind of why I made the site, except I have a terrible memory too and it actually helps me as well.

So here is the email I got this morning, left out the personal information.

Message: Hi

Could you help me with script?
I need list of backup files from folder but my script doesnt work properly.

Get-ChildItem “\\machinename\G:Backup$” | Select-Object Name, CreationTime, @{Name=”Kbytes”;Expression={$_.Length / 1Kb}}

Thanks for help.
Adam

So in looking at this- the Get-ChildItem is the correct commandlet for the job here. We know that Get-ChildItem works like the old school, “dir” command- so this works.

Just looking at the syntax, you may want to check the share name too, usually with a share, I’ve seen a “$” after the G. So in otherwords:
\\machinename\G$\backup$

Just check it though, not sure of your setup. The easiest way would just be to navigate to it through the client computer.

next- Your select statement is awesome. Your label looks great and works like a charm- grats on that.

Adam- another thing to keep in mind is that you must have rights with the account running the script . So if you wrote the script as your user account that doesn’t have rights to the share, right click your powershell ISE or command prompt first and run as a different user and run with admin credentials that have access to the share.

Let me know if that works, doesn’t work!

Got this error recently while trying to run firefox in my Ubuntu server:

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

Being a novice at most linux processes, I didn’t want to just get the fix I wanted to go through the troubleshooting steps.

Obviously there was a problem with a task running, so I took to find a command that would kill processes, simple enough I found a command called kill.

I wasn’t sure which profile the task was running on so I was able to use the command:
killall firefox
And it worked! Gotta be honest, the killall command is pretty sweet sounding anyways..

I’ve had about enough of this…

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System]

Set DisableCMD to 0.

Punks.

So it happens- you are either migrating, updating with a side by side or something just plain happens and you have to restore an existing database to a new machine.

You get your SQL server 2008 R2 install up on a fresh new OS and you get all of your custom settings applied and you restore your database to the machine. Then someone comes back and says it has to be the old name and IP address.

That is no problem.

If you change the NETBIOS name of the machine and change the IP, go ahead and do that now. If you don’t get the person who does that to do that. Rejoin it to the domain then log into your SQL instance(s) one at a time if applicable.

In the instance type: SELECT @@SERVERNAME . Did the name update? Yeah, I didn’t think so.

You will use the system stored procedure:

sp_dropserver <'old_name\instancename'> --(Instance name if applicable once again).
GO

Now that you have dropped the old servername we need to add it back, but we need to make sure the computer knows that it is local:

sp_addserver <'new_name\instancename'>, local
GO

Of course the instance name is applicable as well.

So now you have your machine loaded up- you can also check the jobs to make sure those updated as well:


USE MSDB
GO
SELECT * FROM sysjobs -- this checks the jobs
-- if you need to update them:
UPDATE SYSJOBS SET originating_server = 'newname'

Take it easy now!

Powershell 4.0

Posted: 28th October 2013 by Ben in For the Technical
Tags: ,

It’s released!

I’m going to be jumping into it very soon, but until then:

Read about it!

In the world of SQL, there are a lot of different reasons to do a lot of different things. The particular thing I wanted to do today was to take two tables, that should have been exactly the same and count all the columns of it.

To do this, i used the below query:

SELECT COUNT (*) --Love the Select COUNT
FROM
DATABASE.sys.columns
WHERE
object_id = OBJECT_ID ('DATABASE.schema.TABLE')

It’s had enough. Week after week it grinds away just DOING it’s job and you sit there just programming and being all fat and happy not even acknowledging the hard work it is doing to keep you happy. Well it’s fed up and it won’t be taking any more of your nonsense. Maybe you changed it’s name? Maybe you changed it’s IP address.

Either way, it’s not happy.

So you try to start the service, maybe by bringing it flowers and you simply get: “Access Denied”. You try to go ot the configuration manager, asking if maybe you can take it out sometime to a nice steak dinner, again: “Access Denied.”

What is it SQL server service, what can I do for you? Well, you can start by realizing that I don’t have rights over the TCP/IP schema you specified! By ‘I’, I do mean the SQL Server…not me.

If you’ve changed the IP address of the server, it’s very important to remember this step, otherwise you will be stepping all over yourself trying to realize what the actual problem is!