Tom Grassi

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 110 total)
  • Author
    Posts
  • in reply to: Set-Alias #233650
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Olaf,

    Functions was the answer the work great.

    Thank you

    On to more powershell

    in reply to: Set-Alias #233635
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Guys

    I got it working now found nice video with examples of how to use $PSdefaultParameters

    $PSDefaultParameterValues [email protected]{“Connect-VIServer:Server”=”ESXI11”}
    Set-alias -Name vc1 -Value Connect-VIServer

    Now when I type vc1 I get prompted for my credentials which is great.

    Just one other question on this.
    I have several servers ESXI11 ESXI12 ESXI13 etc.

    Any thoughts On how I can setup those When you run $PSDefaultParmeterValues it overlays the previous one if using the same cmdletname

    Thanks
    Tom

    in reply to: Set-Alias #233497
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Olaf,

    I am new to this $PSdefaultParameterValues command

    PS C:\util> $PSDefaultParameterValues.Add({“ESXI11”})

    Cannot find an overload for “Add” and the argument count: “1”.
    At line:1 char:1
    + $PSDefaultParameterValues.Add({“ESXI11”})
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

    I should be able to do this then if I get the $PSdefaultParameterVaules set right

    Set-alias -Name vc1 -Value Connect-VIServer $PSdefaultParametersVaules

    An example would be great

    Thank you

    Tom

    in reply to: Set-Alias #233482
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Olaf

    Why not an Alias command is suppose to help you with making your life simpler with out typing out a long command line.

    I do not see how $PSDefaultParameterValuses can help

    Also it does not work even if I leave off the -user and the -password

    This should work like scriptblock does

    • This reply was modified 2 months ago by Tom Grassi.
    in reply to: Write-Progress in my profile #233443
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Olaf

    #Requires is that not a comment line:

    The verbose option gives details that I am not interested in seeing

    This code is almost working as I would like

    For ($i=0; $i -le 100; $i++) {
    Write-Progress -Activity “Load VMware PowerCLI” -Status “Current Count: $i” -PercentComplete $i -CurrentOperation “Please wait …”
    Import-Module VMware.PowerCLI
    }

    Just does not count or show bar I have a screen shoot but can not paste in this message how can I add images to here also

    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Kiran,

    I only use the Windows Firewall and WinRM Ports are open.

    I did try by ip address and that failed also.

    Adding the creds Test worked

    PS WSMan:\localhost\Client> Invoke-Command -ComputerName SERVER032 -credential administrator -ScriptBlock {get-service}
    Status Name DisplayName PSComputerName
    —— —- ———– ————–
    Stopped AJRouter AllJoyn Router Service SERVER032
    Stopped ALG Application Layer Gateway Service SERVER032
    Running AppHostSvc Application Host Helper Service SERVER032
    Stopped AppIDSvc Application Identity SERVER032
    Stopped Appinfo Application Information SERVER032
    Stopped AppMgmt Application Management SERVER032
    Stopped AppReadiness App Readiness SERVER032
    Stopped AppVClient Microsoft App-V Client SERVER032
    Stopped AppXSvc AppX Deployment Service (AppXSVC) SERVER032
    Stopped aspnet_state ASP.NET State Service SERVER032
    Stopped AudioEndpointBu… Windows Audio Endpoint Builder SERVER032
    Stopped Audiosrv Windows Audio SERVER032
    Stopped AxInstSV ActiveX Installer (AxInstSV) SERVER032
    Running BFE Base Filtering Engine SERVER032
    Stopped BITS Background Intelligent Transfer Ser… SERVER032
    Running BrokerInfrastru… Background Tasks Infrastructure Ser… SERVER032
    Stopped BTAGService Bluetooth Audio Gateway Service SERVER032
    Running BthAvctpSvc AVCTP service SERVER032
    Stopped bthserv Bluetooth Support Service SERVER032
    Stopped camsvc Capability Access Manager Service SERVER032
    Stopped CaptureService_… CaptureService_bac71 SERVER032

    Adding the creds did the trick

    Thank you

    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug,

    Fat Fingers LOL

    PS C:\util> cd wsman:
    PS WSMan:\> cd .\localhost\client
    PS WSMan:\localhost\Client> set-item .\TrustedHosts -Value ‘SERVER032’

    WinRM Security Configuration.
    This command modifies the TrustedHosts list for the WinRM client. The computers in the TrustedHosts list might not be
    authenticated. The client might send credential information to these computers. Are you sure that you want to modify
    this list?
    [Y] Yes [N] No Suspend [?] Help (default is “Y”): y

    PS WSMan:\localhost\Client> Invoke-Command -ComputerName SERVER032 -ScriptBlock {get-service}
    [SERVER032] Connecting to remote server SERVER032 failed with the following error message : WinRM cannot process the
    request. The following error occurred while using Kerberos authentication: Cannot find the computer SERVER032. Verify
    that the computer exists on the network and that the name provided is spelled correctly. For more information, see the
    about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: (tgcs032:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken

    PS WSMan:\localhost\Client> ls

    WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

    Type Name SourceOfValue Value
    —- —- ————- —–
    System.String NetworkDelayms 5000
    System.String URLPrefix wsman
    System.String AllowUnencrypted false
    Container Auth
    Container DefaultPorts
    System.String TrustedHosts SERVER032

    KIRAN
    From SERVER032 Which is my Work Group Server

    PS C:\util> enable-psremoting -force
    PS C:\util> test-wsman -ComputerName DESKTOP1

    wsmid : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
    ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
    ProductVendor : Microsoft Corporation
    ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0

    DESKTOP1 is my Windows 10 Pro Domain Joined. PS I can invoke-command to all my Desktops and Servers that are domain joined just not this one Work Group server

    I always run Powershell as administrator

    Thank you

    in reply to: NEW-AGROUP How to add Mail attribute #232027
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Hi Doug

     

    Thank you That worked great.

    in reply to: New-adgroup -Managedby not substituting the variable #228649
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Sam

     

    Thanks OMG I did not even see that

     

    It works now and thanks for the shortcut too

    in reply to: Script not reading input on Powershell 7.0 Ubuntu #225369
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug,

    Yes I was searching on the web first I found -ArgumentList but could not get that to work

    You one link had something I did not find before and that worked.

    $server = $args[0]
    $service = $args[1]

    write-host $server
    write-host $service

    invoke-command -computername $server -ScriptBlock { Get-Service $Using:service }

    This works now $Using:

    Thanks now off to the Ubuntu server to test this.

    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug,

    Now that I have OpenSSHUTilS module installed I was able to run this

    PS C:\Users\thomas\.ssh> Repair-AuthorizedKeyPermission authorized_keys
    [*] authorized_keys

    ‘NT AUTHORITY\SYSTEM’ needs FullControl access to ‘authorized_keys’.
    Shall I make the above change?
    [Y] Yes [A] Yes to All [N] No [L] No to All Suspend [?] Help (default is “Y”): y
    ‘NT AUTHORITY\SYSTEM’ now has FullControl to ‘authorized_keys’.
    Repaired permissions

    PS C:\Users\thomas\.ssh> get-acl authorized_keys

    Directory: C:\Users\thomas\.ssh

    Path Owner Access
    —- —– ——
    authorized_keys BUILTIN\Administrators NT AUTHORITY\SYSTEM Allow FullControl…

    PS C:\Users\thomas\.ssh> get-acl authorized_keys | fl

    Path : Microsoft.PowerShell.Core\FileSystem::C:\Users\thomas\.ssh\authorized_keys
    Owner : BUILTIN\Administrators
    Group : OUR\Domain Users
    Access : NT AUTHORITY\SYSTEM Allow FullControl
    OUR\thomas Allow FullControl
    Audit :
    Sddl : O:BAG:DUD:PAI(A;;FA;;;SY)(A;;FA;;;S-1-5-21-3054588571-1341459584-784128302-4702)

    The Repair-AuthorizedKeyPermission command set the proper permissions

    I then restarted sshd

    And now from my Ubuntu server I can run invoke-command with out creds

    I am documenting the process so I can work on my other servers.

    Thank you for your help

    This is resolved.

    in reply to: PowerShell 7.0 Install-Module fails #225198
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug

    I renamed my folder to opensshutils.1.0.0.1
    Then ran your command

    Import-module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1
    and it came back with no errors. I then tested the comdlet I needed and it worked. I think the error message was just information before not sure

    PS C:\ProgramData\ssh> Import-module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1
    PS C:\ProgramData\ssh>
    PS C:\ProgramData\ssh> Repair-AuthorizedKeyPermission

    cmdlet Repair-AuthorizedKeyPermission at command pipeline position 1
    Supply values for the following parameters:
    FilePath:

    PS C:\Users\thomas\.ssh> get-command -module opensshutils

    CommandType Name Version Source
    ———– —- ——- ——
    Function Enable-Privilege 1.0.0.1 OpenSSHUtils
    Function Get-UserAccount 1.0.0.1 OpenSSHUtils
    Function Get-UserSID 1.0.0.1 OpenSSHUtils
    Function Repair-AuthorizedKeyPermission 1.0.0.1 OpenSSHUtils
    Function Repair-FilePermission 1.0.0.1 OpenSSHUtils
    Function Repair-SshdConfigPermission 1.0.0.1 OpenSSHUtils
    Function Repair-SshdHostKeyPermission 1.0.0.1 OpenSSHUtils
    Function Repair-UserKeyPermission 1.0.0.1 OpenSSHUtils
    Function Repair-UserSshConfigPermission 1.0.0.1 OpenSSHUtils

    I am happy now it is installed do not know how it did but it is

    Thank you
    This is now resolved.

    in reply to: PowerShell 7.0 Install-Module fails #225114
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug,

    I was able to extract the file

    PS C:\> Install-Module c:\temp\opensshutils\opensshutils.psd1
    Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9685
    Line |
    9685 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | No match was found for the specified search criteria and module name
    | ‘c:\temp\opensshutils\opensshutils.psd1’. Try Get-PSRepository to see all available registered module
    | repositories.

    Same results
    PS C:\> $PSVersionTable

    Name Value
    —- —–
    PSVersion 7.0.0
    PSEdition Core
    GitCommitId 7.0.0
    OS Microsoft Windows 10.0.17763
    Platform Win32NT
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1
    WSManStackVersion 3.0

    PS C:\>

    Is my powershell current?

    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug

    Yes when I enter the password it presents the results.

    PS /home/thomas> invoke-command -hostname SERV027-N1 {get-service ssh-agent}
    [email protected]’s password:

    Status Name DisplayName PSComputerName
    —— —- ———– ————–
    Running ssh-agent OpenSSH Authentication Agent serv027-n1

    Thanks for responding to my other posting too

    in reply to: PowerShell 7.0 Install-Module fails #225099
    Participant
    Topics: 35
    Replies: 110
    Points: 576
    Rank: Major Contributor

    Doug,

    What do I do with a file type of nupkg ? I did a manual download from the site. gave me opensshutils.1.0.0.1.nupkg.

    I then found this
    https://www.powershellgallery.com/packages/OpenSSHUtils/0.0.2.0/Content/OpenSSHUtils.psd1

    Copy and pasted it

    PS C:\> Install-Module c:\temp\opensshutils.psd1
    Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9685
    Line |
    9685 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | No match was found for the specified search criteria and module name ‘c:\temp\opensshutils.psd1’. Try
    | Get-PSRepository to see all available registered module repositories.

    PS C:\>

    I am on PowerShell 7.0

Viewing 15 posts - 1 through 15 (of 110 total)