To execute Powershell Scripts by passing a parameter to it in a bat file




Powershell  script execution in a batch file 

Let’s learn how to use Vb script to execute a power shell script in a batch file 

Sample Code

if exist "%SCRIPTSFOLDER%\Sample.ps1" start /wait powershell.exe -ExecutionPolicy Bypass -Command "%scriptsFolder%\Sample.ps1" "%Parameter%"

HappyCoding ! 😉

How to establish connection to a remote server through Vb Script




Establishing Connection to a Remote server

Let’s learn how to use Vb script to  establish connection to a remote server by providing credentials.


Sample Code

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Wscript.Echo "PC Name : "& strPCName
Set objWMIService= objSWbemLocator.ConnectServer("" & strPCName & "", _
"Root\CIMv2", _
"" & strUsername & "", _
"" & strpwd & "")

HappyCoding ! 😉

Shared drive details using Vb Script




Shared drive details using Vb Script

Let’s learn how to use Vb script to find the shared drive details on your computer.Below is the sample code 
Sample Code

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 0 to oDrives.Count - 1 Step 2

    WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
Next				 
 

HappyCoding ! 😉




Retrieve “IPConfig” details using Vb Scipt

Sample code for retrieving Ipaddress, Subnetmask and Default gateway using vb script.

Implementation

Const Win32NtwQuery="SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True"
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(Win32NtwQuery)
	For Each objItem in colItems  
		If Not IsNull(objItem.DefaultIPGateway(0))	Then
			If Not VarType(objItem.DefaultIPGateway(0)) =10 then
				wscript.echo "Gateway:-" & objItem.DefaultIPGateway(0)
				If Not IsNull(objItem.IPAddress(0)) Then
					wscript.echo "IpConfig:-" & objItem.IPAddress(0)
				End If
				If Not IsNull(objItem.IPSubnet(0)) Then		
					wscript.echo "SubnetMask:-" & objItem.IPSubnet(0)
				End If
			else
			End If 
		end if 
	Next						 
 

HappyCoding ! 😉

Sample code for Creating XML using groovy

 

 

Simple Code of creating XML using Groovy

Please find sample code for Creating XML using groovy .

Implementation


def writer = new StringWriter()

 

 def xml = new groovy.xml.MarkupBuilder(writer)

 xml.mkp.xmlDeclaration(version: "1.0", encoding: "utf-8", standalone: "yes")

 xml.

 'testfile ' ('xmlns': 'https://soumiaw.wordpress.com') {

     Testkey("Value")

 }

 logger.debug(writer)

                                                                                                                                     

 

HappyCoding ! 😉

Retrieve Time Zone of a computer using Vb script




Retrieve Time Zone of a computer using Vb script

Given below is the code to retrieve Time zone using vb script

Implementation

		Const TimeZoneQuery="Select * From Win32_TimeZone"
		Const TimeQuery="Select * From Win32_LocalTime"
	Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery(TimeZoneQuery)

	For Each objItem in colItems
		Set r = New RegExp
		r.Global = True
		r.Pattern = "\(([^)]+)\)"
		For Each m In r.Execute(objItem.Description )
			TimezoneVal= m.SubMatches(0)
		Next
		Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
		dateTime.SetVarDate (now())

	Next
	Set colItems = objWMIService.ExecQuery(TimeQuery)
	For Each objItem in colItems
		intMonth = objItem.Month
		intDay = objItem.Day
		intYear = objItem.Year
		dtmDate = intMonth & "/" & intDay & "/" & intYear
		intHour = objItem.Hour
		If intHour < 12 Then
			strAMPM = "AM"
		Else
			intHour = intHour - 12
			strAMPM = "PM"
		End If
		intMinutes = objItem.Minute
		If intMinutes < 10 Then
			intMinutes = "0" & intMinutes
		End If
		intSeconds = objItem.Second
		If intSeconds < 10 Then
			intSeconds = "0" & intSeconds
		End If
		dtmTime = intHour & ":" & intMinutes & ":" & intSeconds & " " & strAMPM
		MasterPCTimeZone ="(" & TimezoneVal & ")" & " "  &  dtmDate & " " & dtmTime
		wscript.echo "MasterpcOSTimeZone" & MasterPCTimeZone
	Next	

 

HappyCoding ! 😉

A Programmer’s Life

LOL Hilarious. Re blogging one of my old Post

Geek Girl's avatarGeek Girl !


Theory is when you know something, but it doesn’t work.Practice is when something works, but you don’t know why.Programmers combine theory and practice:
Nothing works and they don’t know why.

Welcome! 😉

View original post

OS Language using Vb script




Retrieve OS Language using Vb script
Given below is the code to retrieve OS language installed in a Computer using vb script
Implementation

Const OSQuery= "Select * from Win32_OperatingSystem"
Const PS1Cmd = "& {(Get-Culture).DisplayName}"

Set WshShell = WScript.CreateObject("WScript.Shell")
	Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery (OSQuery)
	For Each objOperatingSystem in colOperatingSystems
				Set oExec = WshShell.Exec("powershell -command """ & PS1Cmd & """ ")
		strValue=oExec.StdOut.ReadLine()
		wscript.echo "OS Langauge :-" &  strValue
	Next
	

 

HappyCoding ! 😉

Getting Registry value using Vb script span





Getting Registry value using Vb script

Sometime we might face issue while running 32-bit code on a 64 bit operating system
Microsoft has created a new folder called \ Windows \ SysWOW64, which is used to store 32-bit DLLs. In the 32-bit version of Windows, the DLL files are normally stored in \ windows \ system32 folder.
By using the flag __Provider Architecture and StdRegProv we can request access to the 32-bit registers in a 64-bit computer. The caller is connected to 32-bit hive whether it is a 32 or 64-bit applications.

Implementation

Const ProcessorQuery= "SELECT * FROM Win32_Processor"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Const Reg64Value="Software\Microsoft\Wbem\CIMOM"
Const ModelValue="Logging"
Const SWbemNamedValueSet="WbemScripting.SWbemNamedValueSet"
Const SWbemLocator="Wbemscripting.SWbemLocator"
Const GetStringValue="GetStringValue"
Const StdRegProv="StdRegProv"
Const rootkey = &H80000002
Const Key="key="

Set colSettings = objWMIService.ExecQuery (ProcessorQuery)
For Each objProcessor In colSettings
		osbits = int(objProcessor.AddressWidth)
	Next
	if osbits = 64 then
		regValue = GetRegistryValue(Reg64Value,ModelValue)
	ElseIf  osbits = Bit32 Then
		regValue = WshShell.RegRead(RegKey)
	end if

	' Check the registry value
Function GetRegistryValue(Key, Value)

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", 64
Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
Set oInParams = oReg.Methods_(GetStringValue).InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = Value
Set oOutParams = oReg.ExecMethod_(GetStringValue, oInParams, , oCtx)
ReadRegStr = oOutParams.sValue
wscript.echo " Registry value: " &  "" & ReadRegStr
GetRegistryValue = ReadRegStr

End Function

 

HappyCoding ! 😉

 

Time zone of a remote desktop without connecting to it

 

 

 

Time Zone of Remote Server be  retrieved without connecting it.

Solution

Using  PowerShell command “NET Time” ,we were able to get some details on Time zone and time.

Sample 

Local time (GMT+02:30) at \\IPADDRESS is 6/17/2019 4:55:25 PM

HappyCoding ! 😉





The RPC server not available.


Solution

RPC uses a range of dynamic ports (ephemeral ports) to transfer data. The initial connection is made to the endpoint mapping port (135) we were able to establish connection to TCP 135, and at the point a port from the dynamic port range is chosen for further communication. Identify the Dynamic Ports and check if these ports are opened. For firewall, We must ensure these dynamic ports are allowed through the firewall to enable RPC communication/ We Opened these dynamic Ports and this issue was solved

Other Reasons

1. Time Difference
There was a time difference of several hours between the source and target server.

2. Ensure RPC Service is running :

All the services are running as expected
In older versions of windows Service status would be in “Started” instead of Running
DCOM Server Process Launcher: Ensure their status is running and their startup is set to Automatic.

• Remote Procedure Call (RPC):
• RPC Endpoint Mapper:

3. TCP Port 135 for RPC needs to be opened
Ensure that TCP port 135 is opened.

4. Firewall Set up:
Remote assistance and Remote Desktop need to be enabled.

HappyCoding ! 😉

What is a Cursor?

In my old article i had explained how to use a cursor.
Cursor is an data object which is used when we need to manipulate date on row by row basis.ie, when we need to go thro’ each row in the table and then do some manipulations and save it in a temporary table.
Disadvantages of cursor:

1.Each time we fetch a row from the cursor, it result a network round trip, where as a normal select statement query make only one round trip.
2.they Require more resources and temporary storage

Learn More Blog More!

HappyCoding ! 😉

New Technology-New Trends

Every now and then new new ideas are emerging in this world and there is a necessity to grab some of them . Many ideas are modified and improved over time and completely new ideas inevitably spring up every now and then. Ideas can also combine with other ideas to form a powerful new concepts. Change is Inevitable . Historically , many inventions or applications, which have brought changes accordingly sustained and others were perished. Requirements keep on changing so as the Comfort level. 10 Years back , Orkut was very popular, Then came Facebook with more features . People slowing moved from Orkut to Facebook which ultimately lead to its shut down on 2014. Same thing applies to any concept or Organisation.

 

Change is inevitable ! 😉

Being Geeky


Being Passionate for Something makes a Difference 

Being a geek is a great thing. I think we’re all geeks. Being a geek means you’re passionate about something and that defines your uniqueness. I would rather be passionate about something than be apathetic about everything.” –Masi Oka

passion

 

6 long Years


6 Long years of blogging, It’s pretty hard to believe,

Six years by no means makes me an expert, every blog is so different and no set rules apply to all, that’s the beauty of it! Learn More Blog More!

 

6-years

SSRS:Tips and Tricks



For last 4 months. I ve been working in SSRS .So thought of sharing few tips and tricks which i ve used .

First one is filtering,
Scenario if there is no value for a particular column.Hide that column


Code Snippet

1. Right-click the “Details” in the “Row Groups” pane which is in the left bottom, select “Group Properties”.
2. Select “Filters” on the left pane in the Group Properties dialog box.
3. Click “Add” on the top of the right side to add a filter.
4. Click “fx” to the right of the Expression text box.
5. Type in the expression: =IsNothing(Fields!Column.Value).
6. Select “=” from the Operator drop-down list.
7. Type in: =false in the value text box.

next is sorting
Scenario:If we want a field in the alphabetical order or reverse


Code Snippet

1. Right-click the “Details” in the “Row Groups” pane which is in the left bottom, select “Group Properties”. 
2. Select “Sorting” on the left pane in the Group Properties dialog box. 
3. Click “Add” on the top of the right side to add a filter.
 4. Click “ColumnName” to the right of the Expression text box. 5. Give order in the Drop down 

HappyCoding ! 😉

How to get the value of textbox inside the grid using J query





J query Sample-1 To get the value of textbox inside the Grid



Here, we can see how to retrieve the value of text box inside the grid using a jquery”:


Code Snippet


 function RetrieveTextValue() {
        var returnValue = null;
        var rbs = $('[id*=GridRot]').find('input');
        for (var i = 0; i &amp;lt; rbs.length; i++)
         {
             if (rbs[i].checked) {
                 var lblempname = $(&amp;quot;#Rotation_GridRot_lblsearchEmployeeName_&amp;quot; + i).text();
                 returnValue = lblempname
             }
         }
         return returnValue;
    } 

HappyCoding ! 😉

Create your own website, free on WordPress.com.Create your own website.
Start free