I would set the TsProfilePath and the TsHomeDrive.
How can i do that with PowerShell?
In the attribute editor of active directory is no attribute for that.
With Google i found out that i have to use Set-QAdUser.... But Command not found!
Thanks in advance for ideas!
Get-ADUser MyTestUser | Set-ADUser -TsProfilePath "\\srv\profiles$\<username>"
Thats my example but its not working :(
I tried also Get-QADUser and Set-QADUser but the commands are unknown.
I mean the remote desktop attributes! Not the normal ProfilePath. Thats to easy :D
The QAD cmdlets can be found on Quest's website
If you need a pure generic PowerShell answer, I found the following article that explains the process but it doesn't seem too easy: How Can I Edit Terminal Server Profiles for Users in Active Directory?
EDIT: Okay, I got curious so I gave it a try myself and it wasn't that hard actually:
Get-ADUser MyTestUser | ForEach-Object {
$User = [ADSI]"LDAP://$($_.DistinguishedName)"
$User.psbase.invokeset("TerminalServicesProfilePath","\\Server\Share\HomeDir\Profile")
$User.psbase.invokeset("TerminalServicesHomeDrive","H:")
$User.psbase.invokeset("TerminalServicesHomeDirectory","\\Server\Share\HomeDir")
$User.setinfo
}
Quick edit. The last statement $User.setinfo should be $User.setinfo(). Otherwise, you get the OverloadDefinitions statement.
Related
After I imported the module 'virtualmachinemanager' in Powershell (PS 5.1) the cmdlet Stop-Job becomes an alias of Stop-SCJob. I checked that the cmdlet works before importing. Futhermore I tried to make an custom alias for Stop-Job before importing. But sadly that alias also refers to Stop-SCJob after the import.
I also tried to find something on Google, but no luck yet.
Anyone has seen this behaviour before? And more important how do I fix this?
Thanks in advance.
You could simply remove the alias: Remove-Item Alias:\Stop-Job (with -ErrorAction Ignore if you want to handle the case where there's no alias). If you want to refer to the original cmdlet without removing the alias, you can use Microsoft.PowerShell.Core\Stop-Job.
Thanks to Jeroen Mostert
I have a created a custom power shell activity to delete users from a group in A.D.
In the execution command i have given the code like,
Remove-ADGroupMember -Identity "Cab-Approval" -Members Williams,James.Anderson,Jaffer.Hamzad
So, when i clikced on Test Inputs it is giving error like,
enter image description here
SO what is this error, and how to over come this. Can some one help me here
Regards,
Vijay
Welcome to Stack Overflow! Be sure to read the FAQs on how to format your questions. Posting an image is discouraged as we're not able to easily digest it as oppose to pre-formated code blocks. A link to the FAQ for asking is here
That said, it looks like from your error message that you're either running the script remotely or running it from a non-interactive shell. The reason you're receiving this error is because Remove-ADGroupMember prompts you for an Are you sure? response.
You can do the following to mitigate this:
Remove-ADGroupMember -Identity "Cab-Approval" -Members Williams,James.Anderson,Jaffer.Hamzad -Force
The -Force switch will ignore the prompts.
I want to be able to set an email forward in Exchange Powershell O365
I'm trying
Set-Mailbox -Identity emailaddress -DeliverToMailboxAndForward $true -ForwardingSMTPAddress forwardingaddress
but getting
A parameter cannot be found that matches parameter name
'DeliverToMailboxAndForward'.
Do I need to load a snap-in? I can't find any help about this.
You forgot your $'s my friend
Set-Mailbox -Identity $emailaddress -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $forwardingaddress
Also something to look out for when using Exchange Online PSSession (and maybe regular Exchange PSSession) is that it uses the JEA functionality of PowerShell. JEA is Just Enough Administration it actually looks at what roles the account used to connect to the PowerShell Session has and it ONLY gives you the commands that account has the roles to do. I'm not sure if it goes to the level of removing parameters from functions you only have partial access to do. For the missing Cmdlet part though I ran into this while beating my head against the wall writing a batch migration utility come to find out SysAdmin never gave me the permission to do batch migration. As soon as They gave me the permission and I imported the PSSession again BAM Cmdlet was there.
Hope that helps.
I'm trying to check if Windows Deployment Services is installed in server 2016 using powershell and then use this condition to do further steps. I've tried using Get-WindowsFeature but it gives the status list of all roles and features. I want a command that checks whether a single role or feature is installed or not.
My intention is to:
if(WDS is not installed){
Install-WindowsFeature -Name WDS }
else
Do nothing
Facing problem in finding out status of WDS role
Found the answer thanks to #TheIncorrigible1 and #DavidMartin
Using Get-WindowsFeature -Name WDS | % Installed worked.
Also, Get-WindowsFeature -Name WDS | Format-List helps in finding more helpful details.
You can use
param(
[Parameter(Mandatory=$true)][string]$FeatureName
)
(get-windowsfeature |where name -eq $FeatureName).Installstate
Just pass FeatureName to the the variable
I want to take user dump of a process using powershell How can i do it?
The same I get on rightclicking the process in Taskmanager
Based on this article (archived) from Risksense.
MiniDump function from native comsvcs.dll Windows dll could be used.
Like:
Powershell -c rundll32.exe C:\Windows\System32\comsvcs.dll, MiniDump {ID-of-the-process} $Env:TEMP\my_dump_file.bin full
The easiest way is to use Procdump from Sysinternals toolkit. Use Get-Process to get process id, which you can pass to Procdump for actual dumping.
Edit:
I'd still rather use readily available tools instead of the hard way. Have you got a valid business reason? Since you insist, there is a Win32 API call that creates user mode memory dumps. It can be invoked from .Net code, so either use P/Invoke or embed C# into your Powershell code. This is left as an exercise to the reader.
Hi sorry I'm not much help. I've never used a DUP file before. But there is a WMI class called Win32_Process:
Get-WMIObject -Class Win32_Process
Not sure if that's the info you are looking for. Has different properties than Get-Process.
I had a similar use case where I needed to create a dump for an IIS process. Granted I could have used DebugDiag, but I ended up going down this path. Here's what I used (and works pretty well, I should add):
$procid = Get-Process | Where-Object {$_.ProcessName -eq 'w3wp'} | Select-Object ProcessName,Id
New-Item -Path "c:\temp\Dumps" -Type directory -Force
cmd.exe /c "c:\temp\procdump64.exe" $procid.id -accepteula -mp "c:\temp\Dumps"
Furthermore, you could use these dump files for analysis using DebugDiag too. So it's a win-win in my opinion.
PS: Theoretically, one could also get the Process ID using the Get-CimInstance cmdlet. So something like this would also work:
Get-CimInstance -Query "SELECT * from Win32_Process WHERE name LIKE 'w3wp%'"