Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Encode file to base64
- $base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FileName))
- #decode file from base64
- [IO.File]::WriteAllBytes($FileName, [Convert]::FromBase64String($base64string))
- #Additional info
- # http://eddiejackson.net/wp/?author=1&paged=15
- AWS
- Base64 encoding
- If you're using the Amazon EC2 API or a tool that does not perform base64 encoding of the user data, you must encode the user data yourself. If not, an error is logged about being unable to find script or powershell tags to execute. The following is an example that encodes using Windows PowerShell.
- $UserData = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Script))
- The following is an example that decodes using PowerShell.
- $Script = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($UserData))
- For more information about base64 encoding, see http://tools.ietf.org/html/rfc4648
- .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement