Question of PowerShell

Is there a way to make powershell open already pointing to a specific directory, instead of contstantly usind cd?

I just use powershell for programming and it ages to constantly we CD to go to the directory I need.

Is there a way to make powershell open already pointing to a specific directory, instead of contstantly usind cd?

I just use powershell for programming and it ages to constantly we CD to go to the directory I need.

Looking for this first? Heh

http://www.Vistax64.com/PowerShell/65448-PowerShells-default-start-directory.html

http://StackOverflow.com/questions/183901/how-to-start-PowerShell-from-Windows-Explorer

http://superuser.com/questions/287221/how-to-open-a-PowerShell-in-the-current-folder

http://TechNet.Microsoft.com/en-us/library/ee692764.aspx

All those who have a different way to open up Powershell in a place / a particular way.  Perhaps one or more will strike your fancy.

Tags: Windows

Similar Questions

  • Question of PowerShell V2 vs V3?

    Hi all

    I wrote a script that will collect some information.

    I wrote about a client windows 8 and tested again.

    On the client windows 8, it works very well, I have now moved to a windows 2008 Server R2 where I needed to run it on a regular basis, but I see errors.

    Here's the script:

    ------------------------------------------------------------

    (param
    [String] $User
    [String] $Password
    [String] $Hostname
    )

    #Load the VMWare PS snap
    Add-PSSnapin VMware.VimAutomation.Core

    #Connect on VMWare Server
    SE connect-VIServer-Server vcenter-user $user-Password $Password - WarningAction SilentlyContinue | Out-Null

    #Script performance

    $VM = get - vm $Hostname

    $networkadapters = get - vm $VM | Get-NIC
    $disks = $vm | Get-hard drive

    $OSDisk = $disks [0] | % {[string] $_.} CapacityGB}
    $VLAN = $networkadapters [0] | %{[String]$_.NetworkName}
    $mac = $networkadapters [0] | % {[string] $_.} MacAddress}

    --------------------------------------------

    When I run it on the client windows 8 that everything works as expected.

    When I run the present on the Windows 2008 R2 server and then I get the following error messages:

    Impossible to index in an object of type VMware.VimAutomation.ViCore.Impl.V1.VirtualDevice.FlatHardDiskImpl.
    C:\scripts\DiscoverScript.ps1:42 char: 18
    + $OSDisk = $disks [< < < < 0] | % {[string] $_.} CapacityGB}
    + CategoryInfo: InvalidOperation: (0:Int32)], RuntimeException
    + FullyQualifiedErrorId: CannotIndex

    Impossible to index in an object of type VMware.VimAutomation.ViCore.Impl.V1.VirtualDevice.NetworkAdapterImpl.
    C:\scripts\DiscoverScript.ps1:43 char: 26
    + $VLAN = $networkadapters [< < < < 0] | %{[String]$_.NetworkName}
    + CategoryInfo: InvalidOperation: (0:Int32)], RuntimeException
    + FullyQualifiedErrorId: CannotIndex

    Impossible to index in an object of type VMware.VimAutomation.ViCore.Impl.V1.VirtualDevice.NetworkAdapterImpl.
    C:\scripts\DiscoverScript.ps1:44 tank: 25
    + $mac = $networkadapters [< < < < 0] | % {[string] $_.} MacAddress}
    + CategoryInfo: InvalidOperation: (0:Int32)], RuntimeException
    + FullyQualifiedErrorId: CannotIndex

    It seems that on the Windows 2008 R2 server, I'm not allowed to make reference to the index of the table.

    Is it because on windows 2008 R2 Powershell V2 is installed instead of Windows 8, where I have Powershell V3?

    I use the suite version on both machines (W8 & 2008): VMware vSphere PowerCLI 5.1 Release 1 build 793510

    Does anyone know why this is?

    Is it because of the Powershell V2?

    How can I make this work on Powershell v2? Should I just upgrade to v3?

    Thank you!

    Filip

    I think it's really related to a new feature of Powershell v3. It allows you to index in an object, even if it doesn't have an index (see http://blogs.msdn.com/b/powershell/archive/2012/06/14/new-v3-language-features.aspx).

    If the virtual machine has that one disc hard then $disks is not returned as a table, but as an object of hard drive and indexing in it will fail with Powershell v2, but not with Powershell v3.

    -Andreas

  • Question of PowerShell 3.0

    Guys,

    I have powershell 3.0 is installed on my Exchange machine, and when I call my script to exchange for any operation then his call powershell, but after the end of the execution, the window of powershell doent closer automatically... that wasn't the case with v2.0... I used output 0 to closing...
    is that someone encountered the same problem with Exchange 2013 commissioning, because of this... my idm prov process keeps hanging...

    See you soon,.

    Caddick.

    Guys,

    Thanks for your support, I solved the problem.

    -Caddick

  • The E-mail Message body dynamics PowerShell/PowerCLI

    Hello, do not know if I am in the right place to post my question on PowerShell/PowerCLI

    I have a powershell script that will send an e-mail message to an outlook client.

    The body of the msg will have two things-related values: Snapshots Active in the virtual environment and CD-ROM attached to virtual machines.

    Let's talk when the e-mail reports more than a CDROM attached, how to increase or decrease the msg body according to results from the virtual environment?

    So far, I have this code:

    if (($Snapshots -eq "yes")  -or ($cdroms -eq "yes")) { 
    $array0 = @() 
    $array1 = @() 
    $array2 = @() 
    $array3 = @() 
    start-sleep 1 connect-VIServer $vcserver 
    $array0 += Get-VM | get-snapshot | %{$_.VM.Name} $array1 += Get-VM | get-snapshot | select-object -expandproperty Name 
    $array2 += Get-VM | get-snapshot | select-object -expandproperty Created 
    $array3 =@(Get-VM | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name) 
    $i = 0 
    $j = 0 
    Do { 
    $msg.Body += "<FONT COLOR=black>VMware HealthCheck vCenter2</FONT><BR><BR>"  + ` 
    "<B><FONT COLOR=black>Snapshots Active</FONT></B><BR>" + ` 
    "<B><FONT COLOR=black>VM Name</FONT></B>"+` 
    "<B><FONT COLOR=black>                                      ` Name</FONT></B>"+` "<B><FONT COLOR=black>                                      ` Created</FONT></B><BR>"+` "<FONT COLOR=Red>"+$array0+"</FONT>"+` "<FONT COLOR=Red>                                    "+$array1+"</FONT>"+` "<FONT COLOR=Red>                                    "+$array2+"</FONT><BR><BR>"+` "<B><FONT COLOR=black>CDROMS Connected (Bad Habit)</FONT></B><BR>"+"<B><FONT COLOR=black>VM Name</FONT></B><BR>"+"<FONT COLOR=Red>"+$array3+"</FONT>" 
    $i++ 
    $j++
    } Until (($array0[$i] -eq $null ) -or ($array3[$j] -eq $null))

    The result I get is:

    From: VMware Healtcheck

    Sent: Thursday, June 20, 2013 13:26

    From: me

    Re: VMware health UPIvCenter2

    VCenter2 VMware HealthCheck

    Active snapshots

    Name of the created virtual machine

    VEEAM1 VEEAM1 Test1 Test2 20/06/2013 09:06:09 06/20/2013 09:31:15

    Connected CDROMS (bad habit)

    Name of the virtual machine

    MAILGATE

    And I would like is:

    From: VMware Healtcheck

    Sent: Thursday, June 20, 2013 13:26

    From: me

    Re: VMware health UPIvCenter2

    VCenter2 VMware HealthCheck

    Active snapshots

    Name of the created virtual machine

    VEEAM1 Test1 20/06/2013 09:06:09

    VEEAM1 Test2 20/06/2013 09:31:15

    Connected CDROMS (bad habit)

    Name of the virtual machine

    MAILGATE

    NOTE: I have multiple snapshots or multiple virtual machines with CD-ROM connected. Thanks for your help.

    You see not all snapshots is because the loop stops when the snapshots or the cdroms are done.

    Assume that you have 3 entries for snapshots and 2 for the cdroms, you will get only 2 lines each.

    I would do something like that

    if (($Snapshots -eq "yes") -or ($cdroms -eq "yes")) {   $array0 = @()   $array1 = @()   $array2 = @()   $array3 = @()   start-sleep 1   connect-VIServer $vcserver  $vms = Get-VM  $snaps = $vms | Get-Snapshot  $array0 = $snaps | %{$_.VM.Name}  $array1 = $snaps| select-object -expandproperty Name   $array2 = $snaps | select-object -expandproperty Created   $array3 =@($vms | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name) 
    
    # Header  $msg.Body += "VMware HealthCheck vCenter2

    "# Snapshot header $msg.Body += "Snapshots Active
    " $msg.Body += "VM NameNameCreated"# Snapshots 0..($array0.Count-1) | %{ $msg.Body += "
    " + $array0[$_] $msg.Body += "" + $array1[$_] $msg.Body += "" + $array2[$_] + "

    " }# CDRom header msg.Body += "CDROMS Connected (Bad Habit)
    "# CDRoms $array3 | %{ $msg.Body += "VM Name
    "+"" + $_ + "" }}

    Note that I don't check if spacing HTML and page layout is as you wanted. You may need to add some spacing.

  • More than a matter of powershell but you all are great

    Hello everyone, I have a question for you, it's more a question of powershell, but this group is good.  When I look through an object I want the object reference and value, something like that;

    $a = @()

    $t = "" | Select first, last, e-mail

    $t.first = 'Tom '.

    $t.last = "Jones".

    $t.email = " " [email protected] "" "

    {foreach ($view in $t)

    $view

    }

    / code

    This will make me the answers, I want the answer (Tom) and the reference (the first).  Is this possible?

    Thank you

    Tim

    OK, got it.

    Maybe not more elegant solution for this, but it should do the trick

    $a = "" | select Field1, Field2
    $a.Field1 = "abc"
    $a.Field2 = 111
    
    $t = $a | gm -memberType NoteProperty
    for($i=0; $i -lt $t.Count; $i++){
         $name = $t[$i].Name
         Write-Host $name "=" $a."$name"
    }
    
  • DRC for multiple computers...

    Hi everyone;

    Long time reader first time poster...

    I've recently stepped into a new role of the network Admin where we have a mixed eco system of Windows and Mac, all running on a network based on windows that we look on ~ 300 customers worldwide, and I try to take a few cues to help me wise management

    I usually use DRC built into windows for RDP'ing to the computers on the network, which is very practical and that works well, however I'm looking for something a little different and I was wondering if anyone had any suggestions.

    I'm very used to Apple Remote Desktop that allows you to run a scan on a subnet or start and end of the intellectual property extends and it will search the computers, show you all computers on this list and you enable remote control in essentially on a click, I wonder if there's a RDP client that supports this type of functionality also if he supported windows and mac that would be really amazing.

    I also have a few questions of Powershell, but I feel that this is not the appropriate forum for the display

    Thanks for all the help and suggestions in advance.

    See you soon,.

    Gary

    Hello Gary,.

    Thanks for posting your question on the Microsoft community.

    The question will be better suited to the audience of professionals on the TechNet forums.

    I would recommend posting your query in the TechNet forums.

    TechNet Forum
    https://social.technet.Microsoft.com/forums/en-us/home?Forum=w7itpronetworking

    Thank you

  • How can I remove the UTC Timestamp of files saved by FileHistory?

    Given that I had so many problems with Windows 8.1 on my ASUS PC x202e, I backed up my files with the history of the Windows files on a hard drive external and restored the machine to factory settings, so I could start using Windows 8 again, with which I had no problem.

    I record a lot of audio with a freeware recording studio called Audacity, which saves thousands of audio files for each audio project. Because the history of the files rename all files with the timestamp UTC, Audacity does not recognize these thousands of files, unless I have rename removing the timestamp. I have about 7 audio projects that I need to get - it would take several days of tedious to rename all the files.
    For example, the original file name was:
    e0000d79.au
    On my external hard drive, the file appears as:
    e0000d79 (2013_11_24 01_59_07 UTC) .at
     
    Is it possible to somehow restore these files to their original filename without the stamp? I looked in the file history, but was unable to find an option like that.
    Thank you
    James
    EDIT: I thought that it would take some kind of software that runs a script to do that for me. I found this Powershell script to remove the 8 digits after an underscore in any file name:
    Get-ChildItem *.txt |
    Where {$_.Name -match '_\d{8}\.txt' } |
    Rename-Item -NewName {$_.Name -replace '_\d{8}'}
    
    
    
    I had to use Powershell to solve a problem with Windows 8.1 not too long ago, but I'm not familiar with how it works. Y at - it a similar script that I could run? For example, by removing everything that comes after that a beginning parenthesis would work, as there are has no parentheses in the names of the files clean I need clean.

    As I had suspected, historical files offers a device to "restore" your files on your PC that will remove the timestamp, so that copy and paste your files from an external retains the time stamp intact. Are there absolutely no need a complex script or something like that.

    When I restored my computer to factory settings awhile back I changed the name of my machine to something again and I had since started a new file history for the files in the restored machine - in other words, two backups, I seem to stop me to use both, as the main screen of the history of the files only presented me an option - historical files of the current computer.
    However, this was not a problem when I discovered that you can visit history of file to restore files from a previous backup feature.
    1. go in Control Panel
    2. under "System and security" click "Save Backup Copies of your files with history files"
    3. click on "Select Drive" on the left
    4. Select the external hard drive. In my case, I had two backups on the same external.
    5. When you click on your drive, the "Select an existing backup" window appears.
    I have selected the history of files from my old computer, find the files that I was sick of having stamps and restored in a new folder on my desktop. Audacity now recognizes my projects again! Not bad actually.
  • Get-vmswitch causes PowerCLI HyperV query instead of vCenter

    I hope someone can shed some light on that I can't find a similar question elsewhere.

    I recently accidentally typed a powershell "get-vmswitch" command in my window PowerCLI.  Each Get-* I typed after that comes the Hyper-V installed locally instead of the vCenter server, I had been connected to the order information.

    I can repeat the behavior every time.

    PowerCLI opened on my laptop 2012 R2

    to connect-VIServer 192.168.0.16

    Get - VM displays the virtual machines managed by my vCenter Server

    Get-VM-Server 192.168.0.16 #also works

    Get-vmswitch #displays the network cards on my laptop 2012R2

    Get - vm #displays Hyper-V virtual machines on my laptop

    Get-vm-Server 192.168.0.16 # an error no parameter matches Server

    $displayviserver #displays IP address of vCenter expected

    to connect-viserver #appears to work, but all orders always work against the local machine

    My lab is a collection of portable computers running Hyper-V and ESXi.

    I know that get-vmswitch is a powershell for Hyper-V command, but how he reverse my PowerCLI session?

    Is there a way to recover the session other than powerCLI of closing and reopening it?

    LucD,

    Thank you!.  Your answer is correct.  I asked the same question about powershell.com and got the biggest part of your answer, but Peter Jurgens added:

    /********************************************************************************

    Powershell is as easy as loading the snap to access VMware cmdlets from a session:

    Add-PSSnapin vmware *.

    Who will be snap-ins starting with vmware.

    I hope this helps.

    EDIT: I came across a blog from Jeffrey Hicks on this exact issue...

    http://mcpmag.com/articles/2013/08/20/PowerShell-name-duplicates.aspx

    *******************************************************************************/

    http://PowerShell.com/cs/forums/p/19916/42912.aspx

    I added your extra bits to this thread too so anyone falling on each thread will get the most complete answer.

    Between the two of you, I learned a lot about PS and PowerCLI this week.  As an old bash-head pass to Windows/VMware, I need to continue this trend.

    enjoy,

    Von

  • Rounding numbers

    It is more a question generic powershell just about VI Toolkit, but I've been Googling like crazy and have not been able to find an answer yet.  When you use the : function round(), is possible to always round off the result?  So as if it's the 3.1, I want the result ot be 4.  Thank you.

    Well, it's a way to go too.

    I was going to suggest math::ceiling. Math::floor goes the other way.

    Please note that you must add square brackets around math both of the above.

  • PuTTY of appeal via Powershell using Plink - how auto answer the key question of safety

    I'm working on a script that you call PuTTY via Powershell using Plink.exe.  However, we use automatically generated keys, so I need to answer the question "do you trust this security key" during the execution of my script.

    I found through this blog (http://www.virtu-al.net/2013/01/07/ssh-powershell-tricks-with-plink-exe/), you can use ' echo y | Plink.exe", however I do not know where to put this in the script to work properly.  Any help would be appreciated!

    Thank you!

    It's the "-batch ' option.  Remove that fixed the issue.

  • Newbie question - tide may run a remote PowerShell script or BAT file?

    My first post.  I am new to raz, but I've had experience with other planners.

    I have a PowerShell script that must be run on a remote computer.  All the script needs software is installed on this computer.

    In addition, I need the script runs under a service account.  Is it possible and if yes, how can I go about it?

    This work will be be launched manually whenever this is necessary.

    Sure. There are some screenshots. A variable one, I used for the location of the folder on the server of tide (not required but I use a lot of scripts). One for the command of tide itself. The last one is the script runs remotely on windows work. Let me know if they don't make sense.

  • PowerShell plugin question - dynamically create an instance of PowerShellHost in a workflow

    Hi people,

    Whoever did this for a host who has never been in the inventory of PowerShell vCO? More specifically, how Kerberos in the face of a host name which could have been created since the last time tried to Kerberos for authentication of access for?

    See you soon

    I just wanted to let anyone interested know

    I got this works in the following way in a script

    var hostConfig = new PowerShellHostConfig()

    hostConfig.name = "example";

    .

    .

    .

    .

    Download the plugin to create an instance of the host of this configuration by using the update call

    var host = PowerShellHostManager.update (hostConfig);

    If the configuration is correct, you get an instance of the valid host that you can now call commands on. Looking at the Java code for the plugin, the update method does the following

    Check the config for a host ID.

    If ID is found

    then search for this instance and return it

    on the other

    create and validate a new instance of the host for this config and returning

    There are a few side effects / traps to consider here though

    Gotcha 1.     PowerShellHostConfig has no Member for a host ID attribute if you always create a new instance using this method. New instances will appear in your inventory as of the configs duplicate with different instance ID

    Gotcha 2.     During the validation of the hostConfig during the creation of the host, a the connection test is performed using the specified configuration. In other words, you will see that recorded in the log file of the server so it will look like two connections were established in quick succession if you then an invoke on the new host

    Gotcha 3.     Because of the 1 witch hunt, you should probably do PowerShellHostManager.remove (host) at the end of your script

    Gotcha 4.     If you use 3 to clean up inventory know that if your script/workflow terminates with an error/exception then remove it might not happen. Thus, use the error handling, or finally clause in order to ensure that it is executed. Of course if the deletion up a mistake then all bets are off

    Anyway, just thought I'd share

  • Add a PowerShell host workflow question

    Hello people,

    I ran into a problem when I tried to run the add a workflow host Powershell.

    Here's what I've done so now...

    Installed PowerShell plugin in the system of the vCO.

    WinRM service that is configured according to the doc in my vCO server... I want to use the same vCO as a powershell host server too...

    I created the krb5.conf file in the installation of vCO location mentioned in the doc.

    Ran the workflow manage SSL certificates which was a success.

    Now I have to add this as a host of powershell to see in the inventory which fails with the error below.

    Connection timed out: connect (name of the dynamic Script Module: addPowerShellHost #16)

    Your help is very appreciated!

    Kind regards

    VMSavvy

    1. I suggest to add "-a: option of the Kerberos test to connect to the winrm service" This will ensure that the mechanisym of Kerberos authentication is used.

    > winrm identity-r:https:// host_name : port_number -was: Kerberos-sup: user_name Pei:password

    2. try to connect vCO PowerShell plugin using shared session and providing user specifiv credentials (but be sure first that this user has enough privileges to connect to the WinRm service using winrm client)

    > winrm identity-r:https:// host_name : port_number -was: Kerberos-sup: user_name Pei:password

    3. could you give the error reported in vCO?

  • Comand PowerShell for authorization of SIDHistory

    It is that any tool or contain recommended by Microsoft powershell commands that provide the authorization of SIDHistory?

    [Moved from the community centre of Participation]

    It is that any tool or contain recommended by Microsoft powershell commands that provide the authorization of SIDHistory?

    [Moved from the community centre of Participation]

    A quick search on TechNet suggests that this question must be asked in the appropriate Windows Server forum

    https://social.technet.Microsoft.com/search/en-us/TechNet?query=PowerShell%20sid%20History

    Forums-[view all] on the left side

    https://social.technet.Microsoft.com/forums/en-us/home

    Don

  • PowerShell in Win2012

    I need to close the powershell in Win2012 so that when I reboot it will never come again.

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

Maybe you are looking for