I'm trying to create a script that will format the output of w32tm.exe /monitor and display in a table the server name, NTP offset, and RefID.
I'm a little unaware of how to go about getting the output from an executable file to format it and was wondering if someone here could help me. Right now I'm trying this:
$executable = w32tm.exe /monitor
$executable | Format-Table -View "Server Name", "NTP offset", "RefID"
How can I manage to get the executable to be formatted in a table to display those specific parts of the exe?
Hi I also needed to do this before I found a function someone made to do this have a look I am sure you can change it to suit your needs or just use it as is .
ps-function
Article on how it works
Related
I am monitoring witch Check-MK and i know how to get this skript as a service right into Check-MK.
I need just the skript:
check the directory size and I want to get an alert if it didnt change after 1,5h
to check the folder size:
folder_size=$(du -bs /backup/log |
after the "|" i want to check this with time
am I right so far?
thx for help <3
You can write a simple local check, that does what you need, if Checkmk's built-in file age checks do not meet your requirement.
I am trying to run this command on cmd:
wmic:root\cli>/node:IPAddress product get name, version, vendor, installdate
IPAddress can be replaced with whatever address or hostname is desired.
The command does not give me any errors, however, it gives me installdate in MMMMYYDD form (for example, 20170801 instead of something simple like 01-Aug-2017 or 2017/08/01). I have tried to look for solutions online, but they're usually talking about system installations instead of product installations.
I know that installdate is a string, so this is more a question of how should I convert this string into a date. I tried using '+%Y%m%d' after the installdate, but it gave me an error: Invalid GET Expression.
If you can use PowerShell, it is not too difficult. You can control the format you want in the ToString method.
Get-CimInstance -ClassName CIM_Product |
Select-Object -Property #{n='Name';e={$_.Name}}, #{n='Date';e={([datetime]::ParseExact($_.InstallDate,'yyyyMMdd', $null)).ToString('dd-MMM-yyyy')}}
I'm currently working on a project where I search hundreds of files using findstr in the command line. If I find the string which I searched for, I want to proceed with this exact file (and the other ones that include my string).
So in my case:
I searched for the string WRI2016 by using:
H:\KOBINI>findstr "WRI2016" *.ini > %temp%\xx.txt && %temp%\xx.txt
To see what the PC does, I save it in a .txt file as you can see.
So if my file includes WRI2016 I want to extract some facts out of the file. In my case it is NR, Kunde, WebHDAktiv, DigIDAktiv.
But I just can't find a proper way to link both of these functions.
At first I simply printed all of the parameters:
H:\KOBINI>findstr "\<NR Kunde WRI2016 WebHDAktiv DigIDAktiv" *.ini > %temp%\xx.csv && %temp%\xx.csv
I also played around using the if command but that didn't really work out. I'm pretty new to this stuff as you'll see in my following tries to solve this problem:
H:\KOBINI>findstr "\<NR DigIDAktiv WebHDAktiv" set a =*.ini findstr "WRI2016" set b =*.ini if a EQU b > %temp%\xx.txt && %temp%\xx.txt
So all I wanted to achieve with that weird code was: if there is a WRI2016 in the file, give me the remaining parameters. But that didn't work out at all.
I also tried it with using new lines for every command which didn't change a thing.
As I want this to be a .csv in the end I want to add a semicolon between my parameters, any chance how I could do that? I've seen versions using -s";" which didn't do anything for me.
Sorry, I'm quite new and thought I'd give it a shot.
an example of my .ini files Looks like this:
> Kunde=Markt
> Nr=101381
> [...]
> DigIDAktiv=Ja
> WebHDAktiv=Nein
> Version=WRI2016_U2_P1
some files have a different Version though.
So I only want to know "NR, DigIDAktiv ..." if it's the 2016 Version.
As a result it should be sorted in a CSV, in different columns.
My Folder Looks like this
So I search These files in order to find Version 2016 and then try to extract my Information and put it into a .csv
Here's my situation:
We depend on users to click some .bat and do the daily-backup.
I did some batching programming, now when they (are forced to) back-up, it leaves a log file in it's own the server folder. And yes, they need to be forced otherwise they just won't do the g.damn backup... Welcome to my company.
Then, after some more research, I developed another bat which checks if the file is outdated and prints it on a text file.
This is the kind of files that I have now:
File: DailyBkp
Content:
".\John\log.log"
".\Department1\Andy\log.log"
".\Department1\Nicole\log.log"
".\Department2\Ann\log.log"
File: Departments
Content:
Department1
Department2
...
Great, after some string treatment in PowerShell I managed to get DailyBkp content to be this:
John
Department1 Andy
...
Note that it has a space at beginning and another at the end which won't go away no matter what trim I use...
So now I have this setup: SERVER > E:\Backup\
Inside backup we have i.e. "Department 1" ... "Dep.-N"
Inside each one: "User-Lastname1" .. "User-lastname-N"
What I need, or what I do want to is use PowerShell to get the contents of DailyBkp containing "Dept_User" string, and export entries to a csv file like this:
COLUMN_Name COLUMN_Dept
Andy Department1
So, how do I do this? I can't find anything on internet that uses text files.
so assuming I am reading your question correctly you have a DailyBkp file that looks like this:
Department1 Andy
Dpeartment2 Jim
...
to get what you want you could read each line in split it out then spit it back out in a csv like this:
"COLUMN_Name,COLUMN_Dept" | out-file <path>\outfile.csv
$bkpFile = get-content $dailyBkpFile
$bkpFile | ForEach-Object {$line = $_.split(" ")
"$($line[1]),$($line[0])" | out-file <path>\outfile.csv -Append}
output should look like this:
COLUMN_Name,COLUMN_Dept
Andy,Department1
Jim,Department2
just doind a quick post here.
My question was answered, thanks.
And, if anyone is interested in Powershell programming, google Mastering Powershell by Tobias Weltner; this is a free book with lots of explanations.
I'm creating a test case using selenium RC.
The General flow of the process is to get data from an Excel File.
Then run the SeleniumRC.
To get the result I place a printout command. All output is visible in the console. (using eclipse)
What I need to do next is to store all this data into a new Excel File. Can anyone help me on how to generate my output into an excel file.
Store the result in variables and then write them into the excel using the Java Excel API.
Use Jexcel API.This link may be useful to you.
http://r4r.co.in/java/apis/jexcel/
A simply way I will suggest is to append all the printout statements in a storage variable like string buffer(Java) with delimiters like | symbols at the end of each line and then write this information into a text file.(line by line by split with the help of | symbols)
If you want to store this information in excel you will have to use the Apache POI Project to write data into excel sheets.(http://poi.apache.org/)