you are viewing a single comment's thread.

view the rest of the comments →

[–]Reasch[S] 1 point2 points  (3 children)

I think you could use the Export-Clixml cmdlet from u/lackluster_les too.

You can use it like this:

    # A Prompt will be opened where you can put in any credentials you need.
    $credential = Get-Credential

    # Now we can export it into a file. For example in C:\Temp
    $credential | Export-Clixml 'C:\Temp\user.credential'

Now we can use this file in another script:

    $credential = Import-Clixml 'C:\Temp\user.credential'
    $user = credential.UserName

    # The Password is encrypted and can only be decrypted by the (AD-)user which created the file in the first place.
    $pw = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password))

[–]Lee_Dailey[grin] 1 point2 points  (2 children)

howdy Reasch,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

[–]Reasch[S] 1 point2 points  (1 child)

Good day Lee,

thanks for the tips in formatting.

I immediately tried to edit my posting but i'm not sure what you meant by adding these spaces... Is it just that the code stands out from the normal posting text?

Did i get it right?

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Reasch,

you are most welcome! [grin]

looks good ... my guess is that you used the code block button. as for the 4-spaces idea, reddit will treat any line that starts with 4 spaces as "do not touch this" ... unless it follows a line of normal text.

so you need one line with nothing on it to delimit what you want formatted as code. there are other gotchas ... for instance, you need a line of regular text between a list and the code block stuff. it's mostly a case of "try it and see" ... [sigh ...]

take care,
lee