Carbon 2.0.0 is out. You can download Carbon as a .ZIP archive, NuGet package, Chocolatey package, or from the PowerShell Gallery. It may take a week or two for the package to show up at chocolatey.org.
Overview
Carbon version 2.0 is a huge release, with lots of new enhancements and bug fixes. We hope you like them. Carbon 2.0 now requires PowerShell 4, so it is not backwards-compatabile with Carbon 1.x. Because of this, we made some additional backwards-incompatible changes. See the Upgrade Instructions section for things to look out for.
If you’re upgrading from a previous 2.0 alpha release, you’ll want to review the changes since your alpha version (found after the Upgrade Instructions section). We improved backwards-compatability with Carbon 1.x since the last alpha release, but that broke compatability with the alphas.
Upgrade Instructions
Make sure you’re running PowerShell 4.
Install-Certificate’s parameters have changed:
- Remove the
Exportableswitch from any usages ofInstall-Certificatewhen installing from anX509Certificate2object, since that switch only gets used when installing a certificate from a file.
Some functions now return different objects and/or the objects returned have changed:
- Use the
Sidproperty on objects returned byTest-Identitywhen using thePassThruswitch: it now returns aCarbon.Identityobject if the identity exists and you use the-PassThruswitch, e.g.Test-Identity -Name $userName -PassThru | Select-Object -Expand 'Sid'. - Update usages of
Carbon.Computer.ProgramInstallInfo’sVersionproperty (returned byGet-ProgramInstallInfo). It was anintand is now a Version object.
The Carbon assembly was re-organized. If you were reaching into Carbon.dll (NOT RECOMMENDED), you’ll want to:
- Rename usages of
[Carbon.AdvApi32]class to[Carbon.Service.ServiceSecurity]. - Rename usages of
[Carbon.Lsa]class to[Carbon.Security.Privilege]. - Rename usages of
[Carbon.Win32]class to[Carbon.FileSystem.Path]. - Rename usages of
[Carbon.HandleInfo]class to[Carbon.Win32.HandleInfo]. - Remove usages of
[Carbon.Lsa]::LookupPrivilegeValueclass method. It was incorrectly exposed as a public method. - Remove usages of
[Carbon.Kernel32]::LocalFreeclass method. It was incorrectly exposed as a public method.
The following commands no longer return the stdout output from the console applications each one calls. To see the old output, use the -Verbose switch. Remove any usage of the output you were processing.
- All IIS functions.
Disable-FirewallStatefulFtpEnable-FirewallStatefulFtpInstall-ServiceInstall-SmbShareRemove-SslCertificateBindingSet-SslCertificateBindingUninstall-Service
The following functions' internal behavior has changed. This may or may not impact you.
Grant-Permissionnow only grants permissions on an object if those permissions aren’t present. To preserve previous behavior, add the-Forceswitch to allGrant-Permissionusages.Grant-Permissionnow writes an error if you don’t have access to a private key. Previously, it would skip the key without any messages.Install-Msi(fkaInvoke-WindowsInstaller) now only installs the MSI if it isn’t already installed. To preserve the previous behavior and always install, add the-Forceswitch to allInvoke-WindowsInstaller`Install-Msi` usages.- All IIS functions were re-written to use the
Microsoft.Web.AdministrationAPI instead ofappcmd.exe. Install-IisWebsiteno longer deletes and re-creates websites. If a website exists, it updates its configuration to match parameters passed in. To preserve previous behavior and delete the website before installing, use the-Forceswitch.Install-IisVirtualDirectoryno longer deletes and re-creates virtual directories. If a virtual directory exists, its configuration is updated in place. To preserve previous behavior and delete the virtual directory before installing, use theForceswitch.Install-FileShare(fkaInstall-SmbShare) no longer deletes and re-creates the share, instead it modifies existing shares in place. To preserve previous behavior and delete existing shares before re-creating, use theForceswitch.Set-RegistryKeyValueonly sets the value if the value doesn’t exist or the current value is different than the desired value.
We’ve added parameter validation to some functions. This shouldn’t impact anybody, since if you were passing data that breaks this new validation, the function wouldn’t have worked even in previous versions of Carbon.
- Ensure that all thumbprints passed to
Set-SslCertificateBindingare valid (40 character hex strings), since it now validates thumbprints. - Check that all IP addresses passed to
Set-HostsEntryare valid IP v4 or v6 addresses.Set-HostsEntry’s IPAddress parameter is now aSystem.Net.IPAddressobject. Previously it was a string validated with a regular expression, so you should be OK.
All Carbon functions now respect each caller’s common parameters (e.g. -Verbose, -ErrorAction, etc.). This means if you pass a common parameter to a script that calls a Carbon function, that Carbon function will use that common parameter. This may or may not impact you.
Bug Fixes
- Carbon’s
System.ServiceProcess.ServiceControllerextended type data causes errors when PowerShell formatsSystem.ServiceProcess.ServiceControllerobjects that represent services on remote computers. Compress-Itemdoesn’t remove handled errors from global error array.Grant-Permissionfails with an unhelpful error message if it is unable to get the ACL on a private key.Install-Msididn’t properly detect when installation failed.Install-ScheduledTaskfails under PowerShell 5 to create a scheduled task to run on Sunday.Install-Service:- No longer writes a warning about being unable to stop an already stopped service (fixes issue #158).
- Starting the service now respects caller’s error action preference. Before,
Start-Servicewould write an error even if somone calledInstall-Servicewith anIgnoreorSilentlyContinueerror action preference. - Service arguments that are quoted still get quoted. Now, quotes are trimmed before arguments are quoted.
Set-EnvironmentVariablefails to set process-level environment variable.Set-HostsEntryfails to preserve whitespace if existing lines end with a comment/description. Thanks to Konstantin Ushenin for the fix.
Enhancements
General
- Carbon now requires PowerShell 4.
Import-Carbon.ps1is more intelligent about when it tries to re-load Carbon. It will force a re-import of Carbon if any of Carbon’s files have changed or the version has changed.- Added new
FileIndex,LinkCount, andVolumeSerialNumberextended type data onSystem.IO.FileInfoobjects for getting a file’s index, its hard link count, and volume serial number, respectively. - The product version of the Carbon assembly now includes pre-release version information, as defined by the Semantic Versioning specification. To get this version, run
Get-Item Carbon.dll | Select-Object -ExpandProperty 'VersionInfo' | Select-Object -ExpandProperty 'ProductVersion'. - The Carbon NuGet package now supports installing and uninstalling under Chocolatey.
- All IIS functions were re-written to use the
Microsoft.Web.AdministrationAPI instead ofappcmd.exe. As a side effect, they no longer returnappcmd.execonsole output. - The following functions no longer use
Write-Host. Instead, they useWrite-Verbose:Disable-NtfsCompressionEnable-NtfsCompressionGrant-ComPermissionGrant-PermissionInstall-ServiceRemove-SslCertificateBindingRevoke-ComPermission
- Created default, table-based display formats for
System.DirectoryServices.AccountManagement.UserPrincipal,System.DirectoryServices.AccountManagement.GroupPrincipal,Microsoft.Web.Administration.ApplicationPool,Microsoft.Web.Administration.Site, andMicrosoft.Web.Administration.Applicationobjects. - Re-organized Carbon’s internal directory structure. You shouldn’t be reaching into Carbon’s internals, so this shouldn’t matter, but wanted to let everyone know just in case.
New Functions
Clear-DscLocalResourceCacheclears the local LCM’s DSC resource. This makes developing resources easier.Clear-MofAuthoringMetadataremoves authoring metadata from .mof files.Copy-DscResourcecopies DSC resources (ZIP files, MSI archives, MOF files, etc.), including timestamps, checksums, and copying only changed files.ConvertTo-SecurityIdentiferconverts a binary, string, orSystem.Security.Principal.SecurityIdentifierobject into aSystem.Security.Principal.SecurityIdentifierobject.Get-DscErrorgets any DSC errors that were written to a computer’s DSC event log.Get-DscWinEventgets DSC events that were written to a computer’s DSC event log.Get-FileSharePermissiongets the sharing permissions on a file/SMB share (not the NTFS file system permissions).Get-FileShareuses WMI to getWin32_Shareobjects for the file shares installed on the local computer.Get-Groupgets a local group or all local groups.Get-Msireads installer information and properties from an MSI file.Get-PowerShellModuleInstallPathgets the path where new module’s should be installed. Beginning with PowerShell 4, modules should get installed into$env:ProgramFiles\Windows PowerShell\Modules. Under PowerShell 3, it is$PSHome\Modules. This function returns the correct location for the version of PowerShell you’re using.Get-Usergets a local user or all local users.Initialize-Lcmconfigures the DSC Local Configuration Manager on computers, including installing the private key needed for decrypting credentials.Remove-GroupMemberremoves a user/group from a local group. Thanks to Philip Kluss for the contribution.Resolve-Identityconverts a system, local, or domain principal name or a SID (as aSecurityIdentifer, string SDDL, or byte array) into its canonical representation and includes extended identity information: domain, type, and SID.Start-DscPullConfigurationstarts a configuration check on a computer that is configured to use the PULL refresh mode.Test-DscTargetResourcecompares target resource with desired resource. Helpful when writingTest-TargetResourcefunctions.Test-Groupchecks if a local group exists.Test-FileShareuses WMI to check if a file/SMB share exists on the local computer.Test-TypeDataMembertests if a type has an extended type member defined.Uninstall-FileShareuninstalls/removes a file share, if it exists.Write-DscErrorwrites DSCErrorLogRecordobjects as errors.
New DSC Resources
Carbon_EnvironmentVariablecreates/removes machine-level environment variables.Carbon_FirewallRuleconfigures firewall rules.Carbon_IniFilemanages the contents of INI files.Carbon_Permissionconfigures file, directory, registry, and certificate permissions.Carbon_Privilegeconfigures an identity’s privileges.Carbon_ScheduledTaskconfigures scheduled tasks withschtasks.exe.Carbon_Serviceconfigures Windows services.
Added PassThru Switches
Added a PassThru switch to the following functions, which will return objects of the given type:
Grant-ComPermission:Carbon.Security.ComAccessRule, representing the granted permission.Grant-Permission:System.Security.AccessControl.AccessRule, representing the granted permission.Install-Group:System.DirectoryServices.AccountManagement.GroupPrincipal, representing the group.Install-IisApplication:Microsoft.Web.Administration.Application, representing the application.Install-IisWebsite:Microsoft.Web.Administration.Site, representing the website.Install-Junction:System.IO.DirectoryInfo, representing new target directories and any new/updated junctions.Install-Service:System.ServiceProcess.ServiceController, representing the service.Install-User:System.DirectoryServices.AccountManagement.UserPrincipal, representing the user.Set-SslCertificateBinding:Carbon.Certificates.SslCertificateBinding, representing the configured binding.
No More Console Output
The following functions no longer return the console output of the program each one runs. Instead, the output is written to the verbose stream (i.e. use the -Verbose switch to see it).
Disable-FirewallStatefulFtpEnable-FirewallStatefulFtpInstall-ServiceRemove-SslCertificateBindingSet-SslCertificateBindingUninstall-Service
Obsolete Functions and Parameters
The following functions are now obsolete. Please don’t use them and stop using them if you are. They will be removed from a future major version of Carbon. You’ll get warnings if you use them.
Complete-Job: It’s total crap. Use PowerShell’sWait-Jobcmdlet instead.Invoke-AppCmd: Switch to Carbon’s IIS functions, or useGet-IisConfigurationSectionto getConfigurationElementobjects from theMicrosoft.Web.AdministrationAPI that you can modify.Resolve-NetPath: Switch to something else. Carbon doesn’t usenet.exeanymore.
The following functions now have obsolete parameters, which will be removed from a future major version of Carbon. You’ll get warnings if you use them.
Install-IisAppPool'sUserNameandPasswordparameters. Use the newCredentialparameter instead.Install-Msi'sQuietswitch.Install-Msialways installs in quiet mode. Please remove usages.Install-Service'sPasswordparameter. Use the newCredentialparameter instead.Install-User'sUserNameandPasswordparameters. Use the newCredentialparameter instead.Set-RegistryKeyValue’sQuietparameter. Please remove usages.
Renamed Functions
The following functions were renamed, but with backwards-compatible aliases in place, so you shouldn’t have to change any code.
Invoke-WindowsInstaller->Install-MsiInstall-SmbShare->Install-FileShare
Switch to System.DirectoryServices.AccountManagement API for User/Group Management
The following functions were re-written to use the System.DirectoryServices.AccountManagement API, introduced in .NET 3.5.
Add-MemberToGroupInstall-GroupInstall-UserTest-UserUninstall-User
Miscellaneous Changes
Get-IisAppPool- Now return all application pools installed on the local computer when called with no parameters.
- Added a default table format for
Microsoft.Web.Administration.ApplicationPoolobjects.
Get-ProgramInstallInfo- Return object’s
Versionproperty changed from anintto a Version object. - Return object’s now have
ProductCodeandUserproperties. If a program doesn’t have a product code, it is set to[Guid]::Empty. TheUserproperty is only set for per-user software installs.
- Return object’s
Get-ServiceConfigurationnow supports services from remote computers.Grant-Permissionnow only grants permissions on an object if those permissions aren’t present. To preserve previous behavior, add the-Forceswitch to allGrant-Permissionusages.Install-Certificate'sExportableswitch is now only allowed when installing a certificate from a file. Previously, you could supply the switch when installing from an X509Certificate2 object but it was ignored.Install-Group'sMembersparameter renamed toMember(with backwards-compatible alias).- Added
Credentialparameter toInstall-IisAppPoolfor increased security and to follow PowerShell guidelines. Install-IisVirtualDirectoryno longer deletes and re-creates existing virtual directories, but modifies existing virtual directories in place.Install-IisWebsite- Added
SiteIDparameter tfor setting a website’s IIS ID. - No longer deletes and re-creates websites, but modifies existing websites in place. This may or may not be a breaking change in your environment.
- Added
Install-MsiPathparameter now supports wildcards.- Now only installs an MSI if it isn’t already installed. To preserve the previous behavior and always install, add the
-Forceswitch to allInvoke-WindowsInstaller`Install-Msi` usages.
Install-Service- Now supports service startup parameters/arguments via the
ArgumentListparameter. - Improved error handling and messages. It now uses
net helpmsgto get helpful error messages based on sc.exe exit codes. - Added
Credentialparameter for increased security and to follow PowerShell guidelines. - Added
Descriptionparameter for setting a service’s description. - Added
DisplayNameparameter for setting a service’s display name.
- Now supports service startup parameters/arguments via the
Install-FileShare(fkaInstall-SmbShare):- Re-written to use WMI isntead of
net.exe, so it no longer returns any console output. - Modifies existing shares in place, instead of deleting and re-creating, unless the share’s path changes. Changing a share’s path requires the old share to be deleted and a new one created.
- Re-written to use WMI isntead of
Install-User- Added
PasswordExpiresswitch for creating accounts with passwords that expire. - Added
UserCannotChangePasswordto prevent user from changing his password.
- Added
Remove-SslCertificateBindinghas better error handling.- Added
SIDparameter toResolve-IdentityNameto resolve a SID into its identity name. Set-HostsEntry'sIPAddressparameter is now aSystem.Net.IPAddressobject. It used to be a string validated with a regular expression.Set-RegistryKeyValue:- Added
UDWordandUQWordparameters for setting registry key values to unsigned integers (i.e. integer values greater than[int]::MaxValueand[long]::MaxValue). Fixes issue #165: Set-RegistryKeyValue rejects unsigned integers larger than [int]::MaxValue. - Deprecated
Quietswitch. - Only sets the value if the value doesn’t exist or the current value is different than the desired value. Use the
Forceparameter to preserve previous behavior.
- Added
Test-Identitynow returns aCarbon.Identityobject if the identity exists and you use the-PassThruswitch. It used to return the identity’s SID. Update scripts to use theFullNameproperty to get the old return value, e.g.Test-Identity -Name $userName -PassThru | Select-Object -Expand 'FullName'.Test-OSIs32Bitnow uses the Environment class’s new Is64BitOperatingSystem property.Test-OSIs64Bitnow uses the Environment class’s new Is64BitOperatingSystem property.Test-PowerShellIs32Bitnow uses theEnvironmentclass’s new Is64BitProcess property.Test-PowerShellIs64Bitnow uses theEnvironmentclass’s new Is64BitProcess property.Uninstall-ScheduledTasknow retries when un-installing a task fails with “The function attempted to use a name that is reserved for use by another transaction.” error.Unprotect-String- Added
AsSecureStringswitch, which will return a secure string instead of a normal string. - The
Passwordparameter now acceptsSecureStringvalues.
- Added
Initialize-Lcm- Added support for PowerShell 5:
RefreshIntervalMinutesdefault value changed to from 15 to 30;RefreshIntervalMinutesminimum value is now 30;ConfigurationFrequency’s minimum value is now 1 (from 2).
- Added support for PowerShell 5:
Changes Since alpha.26
Enhancements
- Includes all changes made in version 1.9.0.
- PowerShell 4 is now required. Carbon won’t even import under PowerShell 3.
- Removed
Carbon_Scriptresource. It only existed so I could pass values to my script blocks. Turns out, the built-inScriptresource supports this with the$using:scope. Remember, your most important features is documentation! - Created a new
Carbon_ScheduledTaskDSC resource for managing scheduled tasks. - The
Versionproperty on the objects returned byGet-ProgramInstallInfois now a proper .NETVersionobject instead of an integer.
Bug Fixes
Carbon_PermissionDSC resource fails when assigning multiple permissions- Grant-Permission fails when clearing multiple existing, non-inherited permission on an item.
Changes Since alpha.31
Bug Fixes
Set-HostsEntryfails to preserve whitespace if existing lines end with a comment/description. Thanks to Konstantin Ushenin for the fix.- Carbon’s
System.ServiceProcess.ServiceControllerextended type data causes errors when PowerShell formatsSystem.ServiceProcess.ServiceControllerobjects that represent services on remote computers. Install-Msididn’t properly detect when installation failed.Set-EnvironmentVariablefails to set process-level environment variable.Compress-Itemdoesn’t remove handled errors from global error array.Grant-Permissionfails with an unhelpful error message if it is unable to get the ACL on a private key.
Enhancements
Import-Carbon.ps1is more intelligent about when it tries to re-load Carbon. It will force a re-import of Carbon if any of Carbon’s files have changed or the version has changed.- Created
Uninstall-Junctionfor uninstalling a junction in an idempotent way (i.e. without errors). Thanks to Konstantin Ushenin for the contribution. - Improved error handling in
Remove-Junction. Install-Service:- Now supports service startup parameters/arguments.
- No longer returns
ServiceControllerobjects by default. This should improve backwards-compatability. Added aPassThruswitch you can use to get aServiceControllerobject returned to you. - Improved error handling. It now uses
net helpmsgto get helpful error messages based on sc.exe exit codes. - Improved handling of arguments/services with spaces in them under PowerShell 5.
- Added
Credentialparameter for increased security and to follow PowerShell guidelines. - Now supports setting a service’s description and display name.
- Starting the service now respects caller’s error action preference. Before,
Start-Servicewould write an error even if somone calledInstall-Servicewith anIgnoreorSilentlyContinueerror action preference.
- New
Test-TypeDataMemberfor testing if a type has an extended type member defined. Install-IisAppPoolno longer returns appcmd.exe output.- Added
PassThruparameter toInstall-IisAppPoolto control when aMicrosoft.Web.Administration.ApplicationPoolfor the installed app pool is returned. Get-ServiceConfigurationand Carbon’s extended type data forSystem.ServiceProcess.ServiceControllerobjects now supports services from remote computers.Uninstall-ScheduledTasknow retries when un-installing a task fails with “The function attempted to use a name that is reserved for use by another transaction.” error.- Added new
FileIndex,LinkCount, andVolumeSerialNumberextended type data onSystem.IO.FileInfoobjects for getting a file’s index, its hard link count, and volume serial number, respectively. Grant-Permissionnow only returns an access rule object when the newPassThruswitch is used. In previous 2.0 alpha releases, it only returned something when permissions on an object were added or changed.Install-Useronly returns a user object when the newPassThruswitch is used. In previous 2.0 alpha releases, it only returned an object if a user was created or updated.Grant-ComPermissionsonly returns an access rule object when the newPassThruswitch is used. In previous 2.0 alpha releases, it only returned an object if permissions were changed.Install-IisApplicationonly returns an IIS application object when the newPassThruswitch is used. In previous 2.0 alpha releases, it only returned an object if the application was created or modified.- Created
Get-Msifunction for reading MSI information and properties from an MSI file. Carbon.Computer.ProgramInstallInfoobjects (returned fromGet-ProgramInstallInfo) now haveProductCodeandUserproperties. If a program doesn’t have a product code, it is set to[Guid]::Empty. TheUserproperty is only set for per-user software installs.Invoke-WindowsInstallerrenamedInstall-Msi, with a backwards-compatibility-preserving alias.Install-Msinow supports wildcards for MSI path to install.Install-Msinow only installs an MSI if it isn’t already installed. To preserve the previous behavior and always install, add the-Forceswitch to allInvoke-WindowsInstaller`Install-Msi` usages.- Added
SiteIDparameter toInstall-IisWebsitefor setting a website’s IIS ID. - Put the
Resolve-IdentityNamefunction back. It was removed from previous alpha releases. Install-IisWebsiteno longer deletes and re-creates websites. This may or may not be a breaking change in your environment.Install-SmbShareno longer returns net.exe output, instead writing it to the verbose stream. To see previous output, use the-Verboseswitch.- Changed
-PasswordNeverExpiresswitch toPasswordExpiresonInstall-Userfor improved backwards-compatability. Set-SslCertificateBindingno longer returns binding objects by default. Use newPassThruswitch to get the old behavior.- The product version of the Carbon assembly now includes pre-release version information, as defined by the Semantic Versioning specification. To get this version, run
Get-Item Carbon.dll | Select-Object -ExpandProperty 'VersionInfo' | Select-Object -ExpandProperty 'ProductVersion' - The Carbon NuGet package now supports installing and uninstalling using Chocolatey.
- Added
AsSecureStringswitch toUnprotect-Stringwhich causesUnprotect-Stringto return a secure string instead of a normal string. Unprotect-Stringnow accepts aSecureStringas the value for thePasswordparameter, which is the password for the private key used to decrypt from password-protected RSA certificate file.- Added
Credentialparameter toInstall-IisAppPoolfor increased security and to follow PowerShell guidelines. - Added
Credentialparameter toInstall-Userfor increased security and to follow PowerShell guidelines. Install-IisVirtualDirectorynow modifies existing virtual directories in place, instead of deleting and re-creating.Invoke-AppCmdis now obsolete and will be removed from a future version of Carbon. Switch to Carbon’s IIS functions, or useGet-IisConfigurationSectionto getConfigurationElementobjects from theMicrosoft.Web.AdministrationAPI that you can modify.- Added
DescriptionandDisplayNameproperties toCarbon_Servicefor setting a service’s description and display name. Grant-Permissionnow writes an error if you don’t have access to a private key. Previously, it would skip the key without any messages.Resolve-Identitynow converts SIDs to aCarbon.Identityobject. The SID may be a string (SID in SDDL form), byte array, or aSecurityIdentifierobject.Get-FileSharePermissiongets the sharing permissions on a file/SMB share (not the NTFS file system permissions).- Created
Get-FileSharefunction. It uses WMI to getWin32_Shareobjects for the file shares installed on the local computer. - Renamed
Install-SmbSharetoInstall-FileShare, with a backwards-compatible alias in place. - Added
SIDparameter toResolve-IdentityNameto resolve a SID into its identity name. - Created
ConvertTo-SecurityIdentiferfunction to convert a binary, string, orSystem.Security.Principal.SecurityIdentifierobject into aSystem.Security.Principal.SecurityIdentifierobject. Install-FileShare(fkaInstall-SmbShare):- Re-written to use WMI isntead of
net.exe. - Modifies existing shares in place, instead of deleting and re-creating, unless the share’s path changes. Changing a share’s path requires the old share to be deleted and a new one created.
- Re-written to use WMI isntead of
Carbon_FirewallRulenow fails with an error if it finds multiple firewall rules with the same name.Set-RegistryKeyValue:- Added
UDWordandUQWordparameters for setting registry key values to unsigned integers (i.e. integer values greater than[int]::MaxValueand[long]::MaxValue). Fixes issue #165: Set-RegistryKeyValue rejects unsigned integers larger than [int]::MaxValue. - Deprecated
Quietswitch. - Only sets value if the value is changed. Use the
Forceparameter to preserve previous behavior.
- Added
Uninstall-Serviceno longer returns sc.exe stdout.