Options

Windows Scripting

murdatapesmurdatapes Member Posts: 232 ■■■□□□□□□□
Do you have to learn VB to know how to script? I was thinking of going the power shell route but wanted to know if you had to start learning VB first?
Next up
CIW Web Foundations Associatef(Knock out some certs before WGU)
ITIL Intermediate Service Operations

Comments

  • Options
    sambuca69sambuca69 Member Posts: 262
    murdatapes wrote: »
    Do you have to learn VB to know how to script? I was thinking of going the power shell route but wanted to know if you had to start learning VB first?

    No. Start VBscripting and PowerShell. Both would be beneficial to learn, and will help you obtain a job.

    I recommend this book. It's old, but a good read: Amazon.com: Windows XP Under the Hood: Hardcore Windows Scripting and Command Line Power (002923672733icon_cool.gif: Brian Knittel: Books
  • Options
    it2bit2b Member Posts: 117
    I've asked this question a few times and the answer is "you should know both". Here's why:

    1. Powershell can't be used for logon scripts (from what I've been read).

    2. You need to install Powershell on all the PCs/servers you want to run the PS scripts on. VBScript will work right away.

    3. There are a ton of free VBScripts on the web since its been around for a long time. A lot of Powershell scripts I've seen just run VBScripts.

    VBScript will not be going away anytime soon. One Technet seminar I attended said that Server 2008 in Core installation mode can't be administered with Powershell. You need to use VBScript.

    That said, Powershell is the way of the future. Many Exchange 2007 features can only be performed with Powershell.
  • Options
    undomielundomiel Member Posts: 2,818
    You can install Powershell on R2 Core machines. That's one of the goodies of the R2 release. Also Powershell can do remote management via WMI without Powershell being installed on the remote machine. Powershell is definitely worth learning. I really need to get back into it, I've been slacking.
    Jumping on the IT blogging band wagon -- http://www.jefferyland.com/
  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    I imagine you could use PS for logon scripts. The problem I see though is that the PCs would have to have PS installed and configured. You would just invoke PS and the script from a batch file. C:\pathtops\ps.exe C:\script.ps1 and additional issue being it would run in the users security context. Any one ever try this?
  • Options
    Hyper-MeHyper-Me Banned Posts: 2,059
    I imagine you could use PS for logon scripts. The problem I see though is that the PCs would have to have PS installed and configured. You would just invoke PS and the script from a batch file. C:\pathtops\ps.exe C:\script.ps1 and additional issue being it would run in the users security context. Any one ever try this?

    But doesnt anything running as a LOGON script run as the user context?

    and shouldnt the same method work for running a PS STARTUP script?

    If you can call CMD.exe at startup, why cant you call PS?
  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    Hyper-Me wrote: »
    But doesnt anything running as a LOGON script run as the user context?

    and shouldnt the same method work for running a PS STARTUP script?

    If you can call CMD.exe at startup, why cant you call PS?
    Yes, you are correct. But one of the advantages of powershell is the ability to run scripts to administer a remote computer under your (not the user's) security context. But you don't get that as a logon script. Sorry I was not clear.

    I would imagine it would be the same. I cannot see why not, but I have never attempted it so I have no idea if there are any issues that need to be tweaked, etc. Once thing I have learned in my life is that just because I assume things are the same or work the same does not mean they are.
  • Options
    it2bit2b Member Posts: 117
    I found this on the Technet Scriptcenter:
    http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/run.mspx

    "By the way, this is the same approach you need to use if you want to run a Windows PowerShell script as part of a logon script. You can’t simply assign a .PS1 file as a logon script; the operating system won’t know what to do with that. Instead, you’ll need to create a VBScript script that calls the PowerShell script:

    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run("powershell.exe –noexit c:\scripts\test.ps1")

    Assign this VBScript script as the logon script and everything should work just fine. (Assuming, of course, that you’ve installed Windows PowerShell on any computers where this logon script is going to run.)"


    Apparently Windows 7 has local policy setting "Run Windows PowerShell scripts first at user logon, logoff" (but we're still running XP so it doesn't help me yet)
    Windows PowerShell Cmdlets for Group Policy
Sign In or Register to comment.