Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

powershell

    Next

  • 1. do not display "ERRORS" when running script without using $errora
    Do you really want not to know of any error? Granted some of noise is not liked in some circumstances. The two parameters you will need to check out are described in the about_CommonParmaters helpfile. Specifically you will want to set ErrorAction to SilentlyContinue and I hope ErrorVariable to <some variable that you will examine later>. This will give you the ability to select how errors are propogated on a per call basis. This will override the global setting ErrorActionPreference. "IT Staff" wrote: > In the scripts which i had, i delibrately search for a *non-existent* > registry in the machine which creates an error. Also i want to run the > script in a command prompt and only display msg via "write-host" instead of > *default error messages* displaying when scripts run. > > # open a registry hive that does not exist on a machine > -- example, do something here that generates an error > -- however error *immediately* appear > > I do not want error message to display. > > I can use $erroractionpreference = "SilentlyContinue" in the first line of > the script. However if i comment out this statement, error message will > definitely appear. Is there a way to NOT TO DISPLAY error msg or CAPTURED > MSG without using the $erroractionpreference = "SilentlyContinue" ? > > > > > > > > > > >
  • 2. PowerShell Remoting equivalent of SSH scp
    I'm trying to use PowerShell v2 to administer a Windows Server 2008 r2 server (I'm trying to move my web hosting from an OpenBSD/Apache box to IIS7 on W2K8r2). The journey has been long and arduous. I'm looking for the equivalent of rsync or scp (secure copy) to deploy files from my development environment into the new server. The server is Internet- facing so I want to run the minimum services required and plug up the firewall to help reduce the attack surface, i.e. no ftp and no file sharing. I was hoping that PowerShell Remoting or WinRS would be the answer (or it would be once I managed to get my configuration issues sorted). I guess the larger question is, without file sharing (i.e. no UNC paths), BITS, ftp, how do I deploy files from Vista to a (non-domain) W2K8r2 server? It seems weird that I can use MMC remotely to modify the firewall, view the event log, start/stop services, etc but I can't get a file from a to b. Hopefully I'm just being dense. Please point me in the right direction. Thanks - Dave
  • 3. SMS text messages to phone via powershell
    Is it possible to send SMS text messages to mobile phone using powershell? If yes, can someone please show the code? For example if i have Mobile phone attrtibute set for user in AD, can i use it to send text messages to him/her?
  • 4. do not display "ERRORS" when running script without using $erroractionpreference = "SilentlyContinue"
    In the scripts which i had, i delibrately search for a *non-existent* registry in the machine which creates an error. Also i want to run the script in a command prompt and only display msg via "write-host" instead of *default error messages* displaying when scripts run. # open a registry hive that does not exist on a machine -- example, do something here that generates an error -- however error *immediately* appear I do not want error message to display. I can use $erroractionpreference = "SilentlyContinue" in the first line of the script. However if i comment out this statement, error message will definitely appear. Is there a way to NOT TO DISPLAY error msg or CAPTURED MSG without using the $erroractionpreference = "SilentlyContinue" ?
  • 5. Running a command from inside a script, command line is corrup
    The ampersand is the call operator, so what it's doing is calling the exe and then passing the rest of the arguments as parameters to the exe command. That's why you don't concatenate the three parameters, they are fed to the command just as if it was a cmdlet or function. I'm not quite sure how to get around the -ss parameter being quoted, though. It's ending up quoted because of the statement $p3 = "-ss:" + $args[0]. Maybe try this: & $exe_path $p1 $p2 -ss:"$($args[0])" thanks, Paul "Raymond Vought" wrote: > Thank you Paul, this is substanially successful and results in this command > line of the spawned process: > > "C:\temp\wlogevent.exe" -c:41 -l:3 "-ss:IIS7 is in place." > > This solves the problem of the spaces after the colons. I am still not out > of the woods though, because I need > > .... -ss:"IIS7 is in place." instead of "-ss:IIS7 is in place." > > I am proceeding to fool around with it. It is very mysterious to me how the > doublequote winds up where it does. Other questions occurr to me: How can > we get away with concatenating the strings without "+" in the line & > $exe_path $p1 $p2 $p3? > > Thank you for your response. > > RFV

Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

Postby ydroam » Wed, 20 Dec 2006 01:21:44 GMT

Is there anyway to add a timestamp to the prompt?

PS 2007-01-01-23:00:01 C:\WINDOWS> echo "echo"
echo
PS 2007-01-03-23:00:01 C:\WINDOWS> ls


Re: Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

Postby ydroam » Wed, 20 Dec 2006 01:29:34 GMT

Found how to customize the prompt by searching for change prompt in
this newsgroup.

function prompt { "PS " + [datetime]::Now + " " + $pwd + ">" } work OK.





Re: Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

Postby ydroam » Wed, 20 Dec 2006 01:31:49 GMT

function prompt { "PS $([datetime]::Now) $pwd> " }






Re: Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

Postby ydroam » Wed, 20 Dec 2006 02:04:48 GMT

2006-12-18T12:04:35 is closer and using (Get-Date) seems better, but
there's something about that T I don't like.








Re: Prompt with Timestamp? PS 2007-01-01-23:00:01 C:\WINDOWS>

Postby /\/\o\/\/ [MVP] » Wed, 20 Dec 2006 03:32:32 GMT

you can also do complete custom formatting like this :

PoSH>(get-date).ToString("yyyy-MM-dd HH:mm:ss")
2006-12-18 19:31:16

Greetings Marc












Similar Threads:

1.Stop and Start a service - wait.com [01/01] - wait.com [01/01]

Let's try that again



In article <3f0f0a3b$ XXXX@XXXXX.COM >,  XXXX@XXXXX.COM  (Ed Siff) wrote:
>This will do it.
>
>Ed
>,|€:>
>y Tom Kihlken - (c) 1987 Ziff Communicati>ns>Co.
>
>In<article , "<llison"  
>>rote:
>>I am using the NETSVC command to stop and start a Windows 2000 servi>>. The
>>only problem is that when I use it in a batch file, the service wi>> stop
>>but not start. I figured out that the reason it isn't starting is >>cause
>>the command to stop the service hasn't finished yet. Is there a comma>> that
>>I can use in my batch file to delay the start request so the stop >>quest
>>can >>ni>>?
>>
>>Here is a copy of my batc>>fi>>:
>>
>>netsvc spooler \\computernam>>/stop
>>(I need a 5 to 10 second delay before the next command takes place, e>>ept I
>>don't know a command to d>>this)
>>netsvc spooler \\computername>>st>>t
>>
>>>ha>>s
>>
>>

Thanks,

Ed

================================================
Ed Siff                     Computing Consultant
Library Systems             CB# 3946
Academic Affairs Libraries  UNC-Chapel Hill
 XXXX@XXXXX.COM              919.962.1288
================================================

"Take me on a trip upon your magic swirlin' ship" -Dylan

2.Cleaning Up the "Windows can perform the same action each time" dialog winbox.jpg (01/01)

3.Open Explorer Showing C Drive Explorer Switches.txt (01/01)

4.Stop and Start a service - wait.com [01/01]

This will do it.

Ed
,|€:
y Tom Kihlken - (c) 1987 Ziff Communications Co.

In<article , "<llison"  
>wrote:
>I am using the NETSVC command to stop and start a Windows 2000 servi>e. The
>only problem is that when I use it in a batch file, the service wi>l stop
>but not start. I figured out that the reason it isn't starting is >ecause
>the command to stop the service hasn't finished yet. Is there a comma>d that
>I can use in my batch file to delay the start request so the stop >equest
>can >in>sh?
>
>Here is a copy of my batc> f>le:
>
>netsvc spooler \\computernam> /stop
>(I need a 5 to 10 second delay before the next command takes place, e>cept I
>don't know a command to d> this)
>netsvc spooler \\computername>/s>art
>
>Th>nks
>
>

5.~~('.')~~~ Wondering how to get a free laptop Free Laptop Info.txt (01/01)

6. how can I get seconds from 1970,01,01

7. ~~('.')~~~ Wondering how to get a free laptop Free Laptop Info.txt (01/01)

8. ~~('.')~~~ Wondering how to get a free laptop Info.txt (01/01)



Return to powershell

 

Who is online

Users browsing this forum: No registered users and 59 guest