For those of us still actually supporting ADO.NET applications, I thought I would jot this one down. J
I wanted to convert a DataRow[] to a DataTable. While DataRow[] are nice, unfortunately they do not support all of the nice features of a DataTable, such as filtering and sorting. Since I needed to further evaluate and sort the DataRow[], I decided that it would be a good idea to go ahead and convert it to a DataTable. Turns out, there is no straight conversion available, so you basically have to create a DataTable and add the rows from the DataRow[] objects. I initially started with this:
// DataTable: Results
// DataRow[]: FilteredResults
public DataTable ConvertToDataTable(DataRow[]FilteredResults)
{
DataTable dt = new DataTable();
foreach (DataRow dr in FilteredResults)
{
dt.Rows.Add(dr);
}
return dt;
}
However, when I ran this code, the application threw the following exception: This row already belongs to another table. It turns out I was ALMOST right, but needed to make a couple of modifications: 1) I needed to create a new DataTable that was a clone of the original DataTable; 2) I needed to use the ImportRow() method rather than the Rows.Add() method.
// DataTable: Results
// DataRow[]: FilteredResults
public DataTable ConvertToDataTable(DataTable Results, DataRow[] FilteredResults)
{
DataTable dt = Results.Clone();
foreach (DataRow dr in FilteredResults)
{
dt.ImportRow(dr);
}
return dt;
}
Most of the projects I work include certificates in some form or fashion. Often the Certificate Authority is something that someone set up once for a specific purpose and forgot about it. When I ask, they can’t tell me which server is their CA.
There are a couple of ways to locate the Certificate Authority(ies) in your Active Directory environment:
- Use the certutil utility from a cmd prompt to determine the CA name and the server hosting the service. This utility is available on newer Windows OSes (I’ve only tried on Windows 2008 R2). This command is particularly useful because it tells you the CA name as well as the server hosting it. The Cert Publishers group will only tell you the server hosting the service. (Thanks to Greig in Sydney for this find.)
certutil –config – -ping |
Today at a client site, we (Cameron, Blake and I) started to look all over the web for an RMSe Visio object and didn’t have much luck. So I ended up creating a new RMSe object and in the process, updated the OpsMgr 2007 Visio Stencil to OpsMgr 2012. Removed are the dreaded RMS objects and new updated objects for SC 2012 Operations Manager. You should be able to edit any of the objects in your own drawings. Here are the new objects included in this stencil:
OpsMgr2012 (Specialized).vss
Report Role with local DB
RMSe
Network Device Arrow with Ports
Windows Server Agent Arrow with Port
Agent Managed Unix/Linux Arrow with Port
Resource Pool
OpsMgr2012 (Servers).vss
RMSe Server
RMSe + Web Console Server
RMSe + Report Server with local RS DB
RMSe + Web Console + Report Server with local RS DB
Agent Managed Servers grouping
Agent Managed Unix/Linux Servers grouping
Network Managed Devices grouping
OpsMgr Consoles grouping
Happy Drawing everyone!
Download:
http://www.systemcentercentral.com/Downloads/DownloadsDetails/tabid/144/IndexID/96587/Default.aspx
With a VBScript you can use the WScript object to check the state of a script and force it to load as elevated. Since the WScript object cannot be used in an HTA script, you cannot perform this same function. However, I have found a work around for this. You can use the ShellExecute method to launch an individual command in an elevated state.
When you use ShellExecute you can enter “runas” for the Operation parameter, it will force the command to execute in an elevated state. This is the equivalent to right-clicking on a file and choosing “Run as administrator.”
In the example below you can see how this can be used to execute an elevated command prompt window.
ShellExecute “cmd.exe”, “”, “”, “runas”, 1 |
Here is another example where it will launch an elevated command prompt and perform a DNS flush
ShellExecute “cmd.exe”, “/c ipconfig /flushdns”, “”, “runas”, 1 |
Of course this is not restricted to command prompts. You can use it to launch any application. The syntax for ShellExecute execute is:
ShellExecute “File”, “Arguments”, “Directory”, “Operation”, Show
Just remember to enter “runas” for the Operation parameter.
Below is an example of what a complete HTA script would look like with the previous two examples added.
<html><head><title>Elevated Command</title> <HTA:APPLICATION APPLICATIONNAME=”Elevated Command” ID=”ElevatedCommand” SCROLL=”no” SINGLEINSTANCE=”yes”/> </head> <SCRIPT Language=“VBScript”> Set objShell = CreateObject(“Shell.Application”)Sub Window_Onload window.resizeTo 360,360End Sub Sub RunCMD objShell.ShellExecute “cmd.exe”, “”, “”, “runas”, 1End SubSub RunFlush objShell.ShellExecute “cmd.exe”, “/c ipconfig /flushdns”, “”, “runas”, 1End Sub</SCRIPT> <body bgcolor=“buttonface”><center><p><font face=“verdana” color=“red”>Elevated Command</font></p>If you do not have local administrator permissions, you will be prompted to supply them. This must be run as a local administrator. <p><input id=runbutton class=“button” type=“button” value=“Launch Elevated CMD” name=“db_button” onClick=“RunCMD”><p><input id=runbutton class=“button” type=“button” value=“Flush DNS” name=“db_button” onClick=“RunFlush”><p></center></body></html> |
For more information on the ShellExecute method refer to MSDN – http://msdn.microsoft.com/en-us/library/windows/desktop/bb774148(v=vs.85).aspx