Skip to main content

Posts

How Invoke-Command works

To know how Invoke-Command works remotely check the below image : Apart from this, lets talk more about Invoke-Command. If you run invoke-command locally will this DeSerialization, conversion to XML etc will happen? the answer is NO. Since you are running it locally all this process are not performed. Further a Deserialized object Type i.e. the data fetched remotely through invoke-command contains only few methods as shown in the below image. Hence suppose you are fetching service info using invoke-command remotely and storing the output in a variable, you won’t get methods to Start or Stop the service. Example : $Service = Invoke-Command -Cn “Test” -ScriptBlock {get-service bits} $Service will show the process details, but you can’t perfom $Service.Stop() or $Service.Start() since its the deserialized data. But you can perform like this : $Service = Invoke-Command -Cn “Test” -ScriptBlock {get-service bits | Stop-Service} This will do the task you are lo...

Simplest way to create a log file with Date and Time using PERL

Hi, today em gonna show the simplest way to create log files and add date and time to it so that we can know which event occurred at what point of time. So lets begin. Fetching and Storing Date and Time : use POSIX qw(strftime); my $now = strftime(‘%d-%m-%Y %H:%M:%S’,localtime); Creating Log File : open ($Log,”+>>”,”/home/amar/MyApplication.log”); Printing contents to Log File : print $Log (“$now ******[START OF SCRIPT : DATABASE CHECK]*******\n”); Full Script : This is the simplest way to create a Logger file in Perl. Hope you all enjoyed the post. Do like and Share for more.

JBPM Time Scheduler Format Explained

Hey Friends, Today am gonna explain you the time format used by JBPM Schuduler. Those who don’t know what JBPM is, its basically a Open Source workflow engine used to execute Business Process. For more details read here : JBPM Wikipedia After lots and lots of googling i got the timer info, hence i am sharing the same below : JBPM SCHEDULER SEQUENCE :  Sec Min  Hour  Day of the Month Month Day of the Week Year So suppose, you wanted to trigger process by : Example 1 : 2 AM Sunday Daily Timer : SEC MIN HOUR [DAY OF MONTH] MONTH [DAY OF WEEK] YEAR 0 0 2 ? * SUN * Here, ? mean you don’t know the exact Day of the Month, so JBPM will automatically find it for you just need to put ? , while * is for all , here in the example it means the process should be triggered in all the Months of a year. Example 2 : 4:25 PM All days of a week Timer : 0 25 16 * * ? Lets increase the complexity, suppose you wanted to execute a script every 2 hours ...

Windows Services Startup Type Explained

Hi Geeks, Today I was working on a Service related script so thought of sharing some useful information related to Services Startup Type which most of the people knows but doesn’t know about the functionality. So lets begin. What are Windows Services and what they do ? Windows Services are the components or applications that starts when your computer is booted up and runs in the background mode helping the application to work smoothly and finally stops when the computer shuts down. For Example, If you want to send or receive any Fax, then the Fax service should be running in the background to perform the Fax activity. How many Service Startup Types are there and what they do ? There are 4 Service Startup Types available : 1. Automatic Explanation : Automatic Service Startup Type starts the service automatically when the system boot up is done. So if we are having a machine of less memory and there are lots of services in Automatic Startup type then your mac...

How to close a Process run by a specific User using PowerShell

Hi Geeks, Today we are going to learn how to close or kill a process run by a specific user. Lets take an example, there are 2 different users : Admin and TestUser , Now Admin and TestUser both are logged into the same machine and performing some important task in Internet Explorer. If Admin does this : Get-Process -Name “iexplorer” It will get all the list of Internet Explorer process run by both Admin as well as TestUser. Now Admin wants to Kill or Stop the Processes which are being executed by him only. So in order to perform this task you can to use the GETOWNER Method. Full Script : Hope you all enjoyed the post, Do Like , Share and comment if you have any query related to this.

How to take Snapshot of the screen using PowerShell

Hi Guys, Welcome to the Powershell Tips and Trick section. Today one of the follower of my page The Powershell Geek asked me how to take Snapshot of the Screen using PowerShell. Before beginning let me tell you , few months back one of my friend got the same requirement from our client i.e. Login to a website, then performing certain tasks and once done take snapshots as a proof that its done successfully. So here’s the Code, its already available in Technet anyways. CODE : OUTPUT IMAGE FILE : So now you can keep the code in between your script or where ever required to take the Snapshot. Hope you all enjoyed it, do Like and Share. Source : Technet

Error Handling Tips in PowerShell

Hi Geeks, We all know the ways to handle error in scripting or programming languages i.e Try, Catch, Finally and so on. The same thing can also be done in PowerShell. Example : Try { $a = 1/0 } Catch { Write-Host “Got Exception” } But suppose your script is too long and you want your Error should be handled in such a way that you can know exactly what caused the error and at which path or line number. So to do so PowerShell provides some cool properties as given below : To Catch the Complete Exception -> $_.Exception To Find the exact Error Line number -> $_.InvocationInfo.ScriptLineNumber To only get the Exception Message -> $_.Exception.Message So will look like this : Try {           Your Script Goes here  } Catch {         $Exception = $_.Exception         $Line = $_.InvocationInfo.ScriptLineNumber         $Message = $Exception.Message } ...