Powershell problem, cannot change directory

ANTONIO ACQUASANTA 1 Reputation point
2022-03-10T16:19:49.273+00:00

So hi everyone! I am new here, and I arrived because of a problem I am having with the powershell. Basically it seems very reluctant at executing Powershell commands, for example for the Set-Location command to change directory. I tried to put "" and later '' on the path, putting and removing the -Path appendix, anything, but it is not executing the command. And plus, it does not even show an error it just doesn't do anything. I added Powershell before the command, because otherwise it was giving me an error regarding not understanding what the command was, hence suggesting that now that the error is gone it knows what command is but cannot execute it. I really need for obvious reasons that this command works ahah! So if anybody could give some hints would be amazing, but for now thank even just for reading! Have a good one,
Stefano

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,244 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Alistair Ross 7,106 Reputation points Microsoft Employee
    2022-03-10T16:38:11.373+00:00

    Can you share what you are doing, most likely a syntax issue but without seeing it, it is hard to diagnose

    181968-setlocation.jpg

    1 person found this answer helpful.

  2. MotoX80 32,911 Reputation points
    2022-03-11T15:21:36.13+00:00

    I'm stuck in the user directory.

    You're in a command prompt and running Powershell and telling it to execute a command. PS runs the command and then terminates. That leaves you back in the command prompt and whatever directory that it has set.

    Just run powershell. Then in the "PS prompt" enter the commands.

    182293-capture1.png

    1 person found this answer helpful.
    0 comments No comments

  3. ANTONIO ACQUASANTA 1 Reputation point
    2022-03-13T13:35:32.047+00:00

    Oh wow thanks a lot it is now moving from one directory to another! I may ask another thing and then quit, now if I ls the directory I finally got in, I receive an error message for not having the permission182552-accessonegatojpeg.gif
    Besides asking for this error, clearly I have not a clear idea of what the powershell is doing, can you suggest me a reading or a topic for understaning it? How does it differentiate from the linux shell? I need to learn this stuff. Thank you a lot again!

    0 comments No comments

  4. MotoX80 32,911 Reputation points
    2022-03-13T14:08:58.363+00:00

    Powershell is Microsoft's shell solution to replace the original command prompt, cmd.exe. You will find many common Linux shell commands are avaiable. These are aliases to PS cmdlets. If you just run Powershell from the Windows start menu it will open and the default directory will be your user account's home directory. From there your ls command should work. If not, then you've done something with accounts or directory permissions. I have no way of knowing what you did.

    You can list the aliases like this.

    PS C:\Users\madne> get-alias
    
    CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Alias           % -> ForEach-Object
    Alias           ? -> Where-Object
    Alias           ac -> Add-Content
    Alias           asnp -> Add-PSSnapin
    Alias           cat -> Get-Content
    Alias           cd -> Set-Location
    Alias           CFS -> ConvertFrom-String                          3.1.0.0    Microsoft.PowerShell.Utility
    Alias           chdir -> Set-Location
    Alias           clc -> Clear-Content
    Alias           clear -> Clear-Host
    Alias           clhy -> Clear-History
    Alias           cli -> Clear-Item
    Alias           clp -> Clear-ItemProperty
    Alias           cls -> Clear-Host
    Alias           clv -> Clear-Variable
    Alias           cnsn -> Connect-PSSession
    Alias           compare -> Compare-Object
    Alias           copy -> Copy-Item
    Alias           cp -> Copy-Item
    Alias           cpi -> Copy-Item
    Alias           cpp -> Copy-ItemProperty
    Alias           curl -> Invoke-WebRequest
    Alias           cvpa -> Convert-Path
    Alias           dbp -> Disable-PSBreakpoint
    Alias           del -> Remove-Item
    ...
    
    
    PS C:\Users\madne> get-help ls
    
    NAME
        Get-ChildItem
    
    SYNOPSIS
        Gets the items and child items in one or more specified locations.
    
    
    SYNTAX
        Get-ChildItem [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device | Directory | Encrypted |
        Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly | ReparsePoint |
        SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude <System.String[]>] [-File]
        [-Force] [-Hidden] [-Include <System.String[]>] -LiteralPath <System.String[]> [-Name] [-ReadOnly] [-Recurse]
        [-System] [-UseTransaction] [<CommonParameters>]
    
        Get-ChildItem [[-Path] <System.String[]>] [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device
        | Directory | Encrypted | Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly
        | ReparsePoint | SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude
        <System.String[]>] [-File] [-Force] [-Hidden] [-Include <System.String[]>] [-Name] [-ReadOnly] [-Recurse]
        [-System] [-UseTransaction] [<CommonParameters>]
    
    
    DESCRIPTION
        The `Get-ChildItem` cmdlet gets the items in one or more specified locations. If the item is a container, it gets
        the items inside the container, known as child items. You can use the Recurse parameter to get items in all child
        containers and use the Depth parameter to limit the number of levels to recurse.
    

    For more info see:

    https://docs.rackspace.com/blog/powershell-101-from-a-linux-guy/

    https://www.sapien.com/books_training/Windows-PowerShell-4

    0 comments No comments