So currently I’ve been on this workday implementation team for a few months now. Because of the environment I am in we are currently a Powershell shop. The task I am assigned with is basically conversion of the workday feed to integrate with our current Provisioning / PIM system along with uploading the generated data …
Monthly Archives: May 2018
Termination PDF Checklist autogenerated via Powershell
Today I ended up working on a task to convert some of my .NET code into more of a scriptable powershell form. I took the interop “itextsharp.dll” below and used the following code to generate a PDF will the fields filled in. The PDF was created using Acrobat pro and I added the functionality to …
Continue reading “Termination PDF Checklist autogenerated via Powershell”
Alessandro Scarlatti – La Folia in D Minor Harmonic
So this was a piece that looked waaaayy more complicated then it is. So at first glance, it’s like Yikes! A lot of notes. So, Let’s take a look. First thing’s fist. “Moderato”, Play at Moderate speed, It seems this speed should feel pretty natural -The Wiki here seems to explain it to be at …
Continue reading “Alessandro Scarlatti – La Folia in D Minor Harmonic”
LANDesk and remote computer memory measured in Bytes.
So here in my environment, we use Intel’s LANDesk software to keep tabs of our asset management. One of the interesting things to find is that LANDesk at the DB level when running reports tend to report the amount of memory it has in bytes instead of Gigabytes, and doing a easy bytes / 1024 …
Continue reading “LANDesk and remote computer memory measured in Bytes.”
Integrating CommVault with VB.NET
Today I knocked out some Comvault code to integrate with our other automation here in our environment, I coded this out in VB.net to match it’s surrounding integrations.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
Imports System.IO Imports System.Net Imports System.Text Imports System.Xml Public Module CommVault Private service As String = "http://FQDNofCommVault.Domain.Com:81/SearchSvc/CVWebService.svc/" Public Function CommVaultLogin() As String Dim user As String = "UserName" Dim pwd As String = "PasswordGoeshere" Dim token As String = GetSessionToken(user, pwd) If String.IsNullOrEmpty(token) Then Debug.WriteLine("Login Failed") Else Debug.WriteLine("Login Successful") End If CVRESTAPIGetClientSample(token) End Function Private Function GetSessionToken(ByVal userName As String, ByVal password As String) As String Dim token As String = String.Empty Dim loginService As String = service & "Login" Dim pwd As Byte() = System.Text.Encoding.UTF8.GetBytes(password) Dim encodedPassword As String = Convert.ToBase64String(pwd, 0, pwd.Length, Base64FormattingOptions.None) Dim loginReq As String = String.Format("<DM2ContentIndexing_CheckCredentialReq username=""{0}"" password=""{1}"" />", userName, encodedPassword) Dim resp As HttpWebResponse = SendRequest(loginService, "POST", Nothing, loginReq) If resp.StatusCode = HttpStatusCode.OK Then Dim xmlDoc As XmlDocument = New XmlDocument() xmlDoc.Load(resp.GetResponseStream()) token = xmlDoc.SelectSingleNode("/DM2ContentIndexing_CheckCredentialResp/@token").Value Else Debug.WriteLine(String.Format("Login Failed. Status Code: {0}, Status Description: {1}", resp.StatusCode, resp.StatusDescription)) End If Return token End Function Private Function SendRequest(ByVal serviceURL As String, ByVal httpMethod As String, ByVal token As String, ByVal requestBody As String) As HttpWebResponse Dim req As WebRequest = WebRequest.Create(serviceURL) req.Method = httpMethod req.ContentType = "application/xml; charset=utf-8" If Not String.IsNullOrEmpty(token) Then req.Headers.Add("Authtoken", token) If Not String.IsNullOrEmpty(requestBody) Then WriteRequest(req, requestBody) Return TryCast(req.GetResponse(), HttpWebResponse) End Function Public Sub CVRESTAPIGetClientSample(token As String) Dim clientPropService As String = service & "client/" + CStr("1005") 'Some Random ID' Dim ClientResp As HttpWebResponse = SendRequest(clientPropService, "GET", token, Nothing) If ClientResp.StatusCode = HttpStatusCode.OK Then Dim xmlDoc As XmlDocument = New XmlDocument() xmlDoc.Load(ClientResp.GetResponseStream()) Debug.WriteLine(String.Format("Client properties response: ", xmlDoc.InnerXml)) Dim clientName As String = xmlDoc.SelectSingleNode("/App_GetClientPropertiesResponse/clientProperties/client/clientEntity/@clientName").Value Dim clientHostName As String = xmlDoc.SelectSingleNode("/App_GetClientPropertiesResponse/clientProperties/client/clientEntity/@hostName").Value Dim clientDescription As String = xmlDoc.SelectSingleNode("/App_GetClientPropertiesResponse/clientProperties/client/@clientDescription").Value Else Debug.WriteLine(String.Format("Get Client properties request Failed. Status Code: {0}, Status Description: {1}", ClientResp.StatusCode, ClientResp.StatusDescription)) End If End Sub Private Sub WriteRequest(ByVal req As WebRequest, ByVal input As String) req.ContentLength = Encoding.UTF8.GetByteCount(input) Using stream As Stream = req.GetRequestStream() stream.Write(Encoding.UTF8.GetBytes(input), 0, Encoding.UTF8.GetByteCount(input)) End Using End Sub Public Function CommvaultLoginDoesNotWork() As String Dim objHTTP = CreateObject("MSXML2.serverXMLHTTP") Dim strEnvelope = "{ ""domain"":"""", ""username"":""svc_User"", ""password"":""MyPassw0rdgoesHere"", ""commserver"":"""" }" Dim InfobloxUsername As String = Environment.GetEnvironmentVariable("CommVaultusername") If InfobloxUsername = "" Then Console.WriteLine("You do not have a username set, enter it now. If not Control+C, in the future use set CommVaultusername=[username]") Environment.SetEnvironmentVariable("CommVaultusername", Console.ReadLine.Trim) InfobloxUsername = Environment.GetEnvironmentVariable("CommVaultusername") End If Dim InfobloxPassword As String = Environment.GetEnvironmentVariable("CommVaultpassword") If InfobloxPassword = "" Then Console.WriteLine("You do not have a username set, enter it now. If not Control+C, in the future use set CommVaultpassword=[password]") Environment.SetEnvironmentVariable("CommVaultpassword", Console.ReadLine.Trim) InfobloxPassword = Environment.GetEnvironmentVariable("CommVaultpassword") End If objHTTP.SetOption(2, 13056) objHTTP.Open("POST", (service & "Login"), False, InfobloxUsername, InfobloxPassword) objHTTP.setRequestHeader("Content-Type", "application/json; charset=utf-8") objHTTP.send(strEnvelope) Dim response As String = objHTTP.responseText Debug.WriteLine(response) If response.Contains("""Error"":") Then Console.WriteLine(response) Environment.Exit(-1) Else Return response End If End Function End Module |