I have pieced together a some powershell to enable Lync for a user and then try to apply policies. The user is created but the policies are not:
# Get domain controller FQDN
$domainName = $Context.GetObjectDomain("%distinguishedName%")
$rootDSE = $Context.BindToObject("Adaxes://$domainName/rootDSE")
$domainControllerFQDN = $rootDSE.Get("dnsHostName")
$lyncServer="coplyncpool."
$registrarPool="coplyncpool."
$sessionOptions = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck
$session = New-PSSession -ConnectionUri https://$lyncServer/ocspowershell -SessionOption $sessionOptions -Authentication NegotiateWithImplicitCredential
Import-PSSession -session $session -AllowClobber
#Enable Lync User
Enable-CsUser -Identity "%displayName%" -RegistrarPool $registrarPool -SipAddress "sip:%userPrincipalName%" -DomainController $domainControllerFQDN
# Sets policies
Grant-CsConferencingPolicy -identity "%displayName%" -PolicyName NoConferencingWithExternalUsers
Grant-CsClientPolicy -identity "%displayName%" -PolicyName NoClientSideArchiving
Grant-CsArchivingPolicy -identity "%displayName%" -PolicyName NoServerSideArchiving
Grant-CsExternalAccessPolicy -identity "%displayName%" -PolicyName NoExternalAccess
Grant-CsMobilityPolicy -identity "%displayName%" -PolicyName NoMobility
Remove-PSSession -Session $session
Here is the error while the policies are trying to be created.:
Management object not found for identity "Geary Eppernator".
Management object not found for identity "Geary Eppernator".
The term 'Grant-CsArchivingPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Management object not found for identity "Geary Eppernator".
Management object not found for identity "Geary Eppernator".
Thanks