windows powershell
1215 TopicsThe term '...' is not recognized as the name of a cmdlet
Hi, I am new to PowerShell. I am running on Win7 and I have the following module installed. I constantly hit with error: The term '...' is not recognized as the name of a cmdlet, function,.... I tried google around for solutions and there is a lot of articles, but only keeps throwing more error after error. Is there anyway to verify what is missing? Can anyone point me to the right direction, any step-by-step guide? Like what needs to be installed first, or how to install guide? Or how to check what is still required? Thanks.Solved408KViews0likes19CommentsUsing Start-Process with -ArgumentList
Hi everyone, I am struggling with the use of Start-Process with an argument list. It may seem obvious for some people but I find it hard to see what is going on here. I have to wait for an installation to end before going to the next step hence the Start-Process. Here is the code: #Copy File $bkFolder = "D:\Temp" $bkFolderExist = Test-Path $bkFolder $OptionFile = "D:\Temp\Option.txt" $fileExist = Test-Path $OptionFile If ($bkFolderExist -eq $false) {New-Item -ItemType Directory -Path "d:\Temp" -Force} If ($fileExist -eq $true) {Copy-Item $dsm $bkFolder} else {$env:COMPUTERNAME | Out-File -FilePath %temp%\Log.txt -Append Exit} #Stop service Stop-Service "Service" #Update Start-Process "install.exe" -Wait -ArgumentList "/s, /v`"INSTALLDIR="D:\Software\App" AllUser=1 RebootYeNo="No" AddLocal="Runtime" REBOOT=ReallySuppress /qn /l*v "C:\Temp\Log.txt"`"" #Copy le fichier dsm dans baclient $oldFile = "D:\Temp\File.txt" $Folder = "D:\Folder" if ($fileExist -eq $false) {Copy-Item $oldFile $Folder} #Start service Start-Service "Service" My problem is that I get an error powershell.exe : Start-Process : A positional parameter cannot be found that accepts argument 'INSTALLDIR=D:\Software\App. It is probably a problem with using some quotes. If there is another way to start a process and wait for it to end before going forward, that will work also. Thank a bunch for the help! MathieuSolved157KViews0likes2Commentspwsh.exe Not recognized, even after adding path?
Hello, I am trying to use PowerShell to install/run Node Red. No experience with PS and very little with CMD. First issue: xxxx cannot be loaded. The file xxxx is not digitally signed. You cannot run this script on the current system..." I went to the Microsoft link provided (https:/go.microsoft.com/fwlink/?LinkID=135170) to read about Execution_Policies I tried to change the policy for a single session using: pwsh.exe -ExecutionPolicy AllSigned To which I got the error: pwsh.exe : The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program..." Looking that up, I found that my 'Environment Variables' were not correct. Specifically, Powershell was not in my path variable. (btw, Why not? There's all types of weird stuff there, why is PS not there?) So I added it to my path. I copy/pasted the .exe location C:\Windows\System32\WindowsPowerShell\v1.0 It still says pwsh.exe is not recognized. Any ideas? Edition Windows 10 Home Version 21H2 Installed on 4/3/2021 OS build 19044.2251 Experience Windows Feature Experience Pack 120.2212.4180.0109KViews0likes6CommentsRun PowerShell with different credentials without prompt on remote machines
I want to run the below command using different user (domain\administrator) without prompting to enter password, basically I want to append the credentials in this command if required. powershell.exe -executionpolicy Bypass -file %script% Expecting: not sure this can be done. powershell.exe -executionpolicy Bypass -file %script% -Credentials -Username user -Password password Thanks,104KViews1like7CommentsExchange Online - Change primary email address, name and alias of a shared mailbox
Hi All, I have been asked by HR to change the email address, name and alias of a few shared mailboxes that were set up last year. For example, I need to change "jobs-mathssec@domain.com" into "jobs-maths@domain.com", and the name/alias consequently. I need to do the same for 9 other mailboxes which have "sec" in the email address. Is it safe to run the following command: set-mailbox jobs-mathssec@domain.com -EmailAddress "SMTP:jobs-maths@domain.com","smtp:jobs-maths@domain.onmicrosoft.com" -Name jobs-maths -DisplayName jobs-maths -Alias jobs-maths Will the old name stay in other properties? I would need to keep all the old emails sent to the old address. Thank you in advance for your help!Solved71KViews0likes5CommentsCannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADUser'
Hi together, i'm quite new to Powershell and need a little 'shove'. :-D What i want to achive: Setting the Manager of a User based on the "ManagedBy" attribute of an OU. What my Script Snippet looks like: # Getting one user & build correct variables (already working for some other scripts) $user = Get-ADUser -Identity ABC $userOUDistName = ($user.DistinguishedName -split "=",3)[-1] $UserOUName = $userOUDistName.Split(",") # Explanation # $user contains the complete information of the user $userOUDistName contains a string like "Department,OU=Users,OU=TEST,DC=DOMAIN,DC=de" So "Department" is the name of OU. $userOUName contains the splitted strings. $userOUName[0] contains the exact word of the OU (in this case "Department" ### Test 1 ### # Fill in the ManagedBy into the new variable $manager # $manager = (Get-ADOrganizationalUnit -Filter * -Properties * | Where-Object {$_.name -eq $userOUName[0]}).ManagedBy # so after this i know who should be the manager for the user # #not working# Set-ADUser -Identity $user.SamAccountName -Manager $manager Error: Set-ADUser : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADUser' required by parameter 'Manager'. Specified method is not supported. At line:1 char:52 + Set-ADUser -Identity $user.SamAccountName -Manager $manager + ~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.SetADUser #working# # writing the exact same value by hand into a new variable # $test = 'Department,OU=Users,OU=TEST,DC=DOMAIN,DC=de' Set-ADUser -Identity $user.SamAccountName -Manager $test Error: #working# Set-ADUser -Identity $user.SamAccountName -Manager 'CN=NAME\, NAME,OU=NAME,OU=NAME,OU=NAME,DC=NAME,DC=de' I already tried this (the same results as before) $manager = (Get-ADOrganizationalUnit -Filter * -Properties * | Where-Object {$_.name -eq $userOUName[0]}).ManagedBy | Out-String Please provide me some hint.. :-D Thank you very much in advance. Greetings, PatrickSolved69KViews0likes2CommentsAccess denied when I want create to File in Powershell
Hi, Please, your help me! I have problem to access denied, when i want create to file. I have the account in the group administrator. I valued the permission in the tab security and i have administrator permission. PS U:\> $cre | Export-Clixml -Path C:\ Export-Clixml : Acceso denegado a la ruta de acceso 'C:\'. En línea: 1 Carácter: 8 + $cre | Export-Clixml -Path C:\ + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Export-Clixml], UnauthorizedAccessException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportClixmlCommand Regards. #PowerShellSolved64KViews1like7CommentsUsing PowerShell to change the User Principal Name (UPN) for a user in Active Directory!
Dear Windows Active Directory friends, I am absolutely aware that there are probably already a lot of articles on this topic. Nevertheless, I would like to show you my steps how I did this in a small infrastructure. But why would I want to change the User Principal Name (UPN)? Let's say you want to synchronize the local Active Directory with the Azure Active Directory and you use in the local domain the DNS suffix e.g. tomrocks.local, then the accounts in Azure are created with the default DNS suffix e.g. yourcompany.onmicrosoft.com. In my case, I added a custom domain in Azure: tomrocks.ch. In order to create the accounts correctly in Azure, the first step is to adjust the UPN of the users in the local Active Directory. I use the PowerShell ISE for this, but of course you may also work with another editor. Please start with the following steps to begin the "journey" (the Hashtags are comments): #The first two lines have nothing to do with the configuration but make some space at the bottom of the ISE. Set-Location C:\ Clear-Host #Get a list of the UPN suffixes Get-ADForest | Format-List UPNSuffixes #Let’s add the UPN suffix Get-ADForest | Set-ADForest -UPNSuffixes @{add="tomrocks.ch"} #Get a list of the UPN suffixes Get-ADForest | Format-List UPNSuffixes #List of all the AD Users in the organization Get-ADUser -Filter * | Sort-Object Name | Format-Table Name, UserPrincipalName #Change the UPN for all the AD users in the organization $LocalUsers = Get-ADUser -Filter {UserPrincipalName -like '*tomrocks.local'} -Properties UserPrincipalName -ResultSetSize $null $LocalUsers | foreach {$newUpn = $_.UserPrincipalName.Replace("tomrocks.local","tomrocks.ch"); $_ | Set-ADUser -UserPrincipalName $newUpn} #Confirm that the UPN is changed Get-ADUser -Filter * | Sort-Object Name | Format-Table Name, UserPrincipalName I know this is nothing spectacular at all, but I wanted to share my findings and experiences with you. Thank you for your attention. Kind regards, Tom Wechsler P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler63KViews1like5Comments