Skip to content

Commit

Permalink
Merge pull request #69 from mod-posh/67-new-credential-cannot-process…
Browse files Browse the repository at this point in the history
…-argument-transformation-on-parameter-password-cannot-convert-the-s3cretpssw0rd-value-of-type-systemstring-to-type-systemsecuritysecurestring

issue-67: Update New-Credential function to accept string password
  • Loading branch information
jeffpatton1971 authored May 26, 2022
2 parents 5094ebf + bbe1c1e commit 3031e9b
Show file tree
Hide file tree
Showing 24 changed files with 2,273 additions and 57 deletions.
2,199 changes: 2,199 additions & 0 deletions ComputerManagement/ComputerManagement-help.xml

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions ComputerManagement/ComputerManagement.psd1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# Module manifest for module 'PSGet_ComputerManagement'
# Module manifest for module 'ComputerManagement'
#
# Generated by: Jeffrey Patton
#
# Generated on: 9/15/2020
# Generated on: 5/26/2022
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'ComputerManagement.psm1'

# Version number of this module.
ModuleVersion = '1.1.2.2'
ModuleVersion = '1.1.2.3'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -32,20 +32,20 @@ Copyright = '9/12/2020 4:02:47 PM'
# Description of the functionality provided by this module
Description = 'A PowerShell module for working with the local computer'

# Minimum version of the Windows PowerShell engine required by this module
# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the Windows PowerShell host required by this module
# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
Expand Down Expand Up @@ -114,11 +114,17 @@ PrivateData = @{
# ReleaseNotes of this module
ReleaseNotes = 'https://github.com/mod-posh/ComputerManagement/blob/master/CHANGELOG.md'

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = ''
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
Expand Down
15 changes: 13 additions & 2 deletions ComputerManagement/ComputerManagement.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,25 @@ function New-Credential {
[Parameter(Mandatory = $true)]
[string]$Username,
[Parameter(Mandatory = $true)]
[securestring]$Password
$Password
)
begin {

}
process {
if ($PSCmdlet.ShouldProcess("New", "New Credential")) {
New-Object System.Management.Automation.PSCredential ($Username, $Password)
switch ($Password.GetType().Name.ToLower()) {
'securestring' {
Write-Verbose "Found SecureString Password";
New-Object System.Management.Automation.PSCredential ($Username, $Password);
}
'string' {
Write-Verbose "Found String Password"
$SecureString = [System.Security.SecureString]::New();
$Password.ToCharArray() | Foreach-Object { $SecureString.AppendChar($_) };
New-Object System.Management.Automation.PSCredential ($Username, $SecureString);
}
}
}
}
end {
Expand Down
Binary file modified README.md
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/Backup-EventLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Backup-EventLogs -ComputerName dc1
The location to copy the logs to.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -47,7 +47,7 @@ Accept wildcard characters: False
The NetBIOS name of the computer to connect to.
```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -63,7 +63,7 @@ The path to the logs you wish to backup. The default logpath
"C:\Windows\system32\winevt\Logs" is used if left blank.
```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Connect-Rdp.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This example shows passing the computernames over the pipe
The hostname or IP address of the computer to connect to

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -69,7 +69,7 @@ A credential object that contains a valid username and password for
the remote computer
```yaml
Type: PSCredential
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Expand Down
10 changes: 5 additions & 5 deletions docs/Export-EventLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To get events and event logs from remote computers, the firewall port for
the event log service must be configured to allow remote access.

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -90,7 +90,7 @@ The
default value is the current user.
```yaml
Type: PSCredential
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Expand All @@ -105,7 +105,7 @@ Accept wildcard characters: False
The full path and filename to where the log should be exported to.
```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -121,7 +121,7 @@ If present the function will list all the logs currently available on the
computer.
```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Expand All @@ -136,7 +136,7 @@ Accept wildcard characters: False
Export messages from the specified LogName
```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-DiskUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ This example shows piping the output through Sort-Object
The path to check

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand Down
6 changes: 3 additions & 3 deletions docs/Get-InvalidLogonAttempt.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ a csv file.
The name of the computer to pull logs from

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -71,7 +71,7 @@ entries.
This can be modified to suit your needs.
```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -90,7 +90,7 @@ this particular script was designed to find a specific entry.
This can be modified to suit your needs.
```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-MappedDrive.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ will be prompted.
The name of the computer to get the list from.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -74,7 +74,7 @@ Accept wildcard characters: False
A credentials object to pass if needed.
```yaml
Type: PSCredential
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-NetShare.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This example shows the basic usage for this function
The name of the server that has file or print shares

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -58,7 +58,7 @@ This will be either Print or Disk
Disk returns file shares
```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand Down
6 changes: 3 additions & 3 deletions docs/Get-NonStandardServiceAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The back-tick (\`) was used for readability purposes only.
The NetBIOS name of the computer to pull services from.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -89,7 +89,7 @@ Accept wildcard characters: False
The DOMAIN\USERNAME of an account with permissions to access services.
```yaml
Type: PSCredential
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Expand All @@ -104,7 +104,7 @@ Accept wildcard characters: False
This is a pipe (|) seperated list of accounts to filter out of the returned services list.
```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-OpenFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This example shows the basic usage of this command.
The NetBIOS or FQDN of the computer

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-OpenSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This example shows the basic usage of the command.
This is the FQDN or NetBIOS name of the computer

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-PendingUpdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Get-PendingUpdates
Computer or computers to find updates for.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-PrinterLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ This is the syntax that I would see being used the most.
The name of your print server.

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -67,7 +67,7 @@ Accept wildcard characters: False
The default log for printing on Windows Server 2008 R2 is specified.
```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-RDPLoginEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This example shows piping the output to Format-Table
This is the NetBIOS name of the computer to pull events from.

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand All @@ -59,7 +59,7 @@ Accept wildcard characters: False
A user account with the ability to retreive these events.
```yaml
Type: PSCredential
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-ServiceTag.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SerialNumber
The NetBIOS name of the computer.

```yaml
Type: Object
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-WinEventTail.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TimeCreated Id LevelDisplayName Message
Specify a valid Windows Eventlog name

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -59,7 +59,7 @@ Accept wildcard characters: False
An integer to show the number of events to start with, the default is 10
```yaml
Type: Int32
Type: System.Int32
Parameter Sets: (All)
Aliases:

Expand Down
Loading

0 comments on commit 3031e9b

Please sign in to comment.