Access office 365 authentication popup of PowerShell from Windows Form/WPF - wpf

I have a following PowerShell script, this scripts connects to my Azure Analysis services. As I execute following script, it opens a popup like image below.
param(
[String]
$envName1
)
$loadInfo1 = [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$server1 = New-Object Microsoft.AnalysisServices.Server
$server1.Connect($envName1)
return $server1
Problem is that I want to execute this PowerShell from my WPF application. I don't understand, how can I access this Popup in my WPF application.

I'm not too sure what you mean by that. However, you need an account to connect to Azure, maybe you signed out or never actually signed in to Visual Studio.
Edit: I finally understand what you mean (slightly). So there are basically two solutions. First one is Azure AD. To connect to Office 355 with PowerShell using the AzureAD module, you’ll first need to install it. You can do so by running Install-Module AzureAD from an administrative PowerShell session. Once you have the module installed, run the Connect-AzureAD cmdlet. Once you do, PowerShell will prompt for your Microsoft ID and password (Work or school account). Once authenticated, you’ll be able to use all of the commands in the module.
Connecting to Office 365 with the MSOnline Module:
Connecting to Office 365 with PowerShell using the MSOnline module requires a little bit more effort. Assuming you have the Microsoft Online Services Sign-In Assistant for IT Professionals RTW software package installed:
Install the MSOnline module from the PowerShell Gallery by running from an administrative PowerShell console:
Install-Module MSOnline (Function)
Once the module is installed, run Get-Module to ensure PowerShell can find the module.
Finally, run the Connect-MsolService cmdlet to authenticate to Azure AD. This will prompt you for your Office 365 credential.

Related

AAD connect provisioning credentials

How can I find the credentials for this?
Please see image below.
I Tried to reproduce the same in my environment to connect using GMSA
First install ACTIVE DIRECTORY DOMAIN SERVICES and create service account for windows server using the below powershell.
Before executing the powershell script, kindly create one Security name GMSA-Test
PrincipalsAllowedToRetrieveManagedPassword is Security Group Name
Import-module ActiveDirectory
Add-KdsRootKey -EffectiveTime ((get-date).addhours(-10))
New-ADServiceAccount <youraccountname> -DNSHostName ITFarm1.contoso.com -PrincipalsAllowedToRetrieveManagedPassword <GMSA-Test> -KerberosEncryptionType RC4, AES128, AES256 -ServicePrincipalNames http/ITFarm1.contoso.com/contoso.com, http/ITFarm1.contoso.com/contoso, http/ITFarm1/contoso.com, http/ITFarm1/contoso
get-ADServiceAccount GMSAtest
Install ADServiceAccount using powershellon AAD Connect Server
Install-ADServiceAccount -Identity <youraccountname>
successfully created service account after ran the powershell commands.
Configure AAD connect with your Service Account.
Service Account Name: your domain\GMSAtest$
Password: PrincipalsAllowedToRetrieveManagedPassword
Reference: Using Azure AD Connect with a gMSA - The things that are better left unspoken (dirteam.com)

How can we pass encrypted password in SQL connection string on PowerShell?

How can we pass encrypted password in SQL connection string on PowerShell?
Unable to connect SQL server with NT AUTHORITY\ SYSTEM account. What teps need to be taken to connect to SQL Server with NT Authority\System account?
As checked, I installed PSTools and extract all files in specific location and ran cmd.
With below cmd
psexec -i -s ssms.exe
After running the above cmd, I got :
couldn't install
Access denied
You dont say much about the client and what you are supposed to achieve. The part about psexec is quite hard for me to understand.
You can use credentials in two ways from local network, sql login and windows login. I assume you are attemting to use windows login.
If you, from a windows computer, run a console app or desktop app, you will connect as the user who started the app. In normal terms, you.
Since you get "NT AUTHORITY\SYSTEM", I guess you want to try as similar as possible like a Windows Service. My recommendation is to start the service as a named user "AD\MyServiceAccount". You give access to this user in SQL server.
I recommend you to read about the differences of:
NT AUTHORITY\System
NT AUTHORITY\NetworkService
AD Account
If you are not trying to debug/build a service, but just want to get some sql server data in an desktop application. Use regular tools and your personal account. If not, sql login.
If you want to use the Computer Account, you should use add AD\$ComputerAccount to ACL list on SQLserver.
Note: AD being the name of your Active Directory.

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication on one machine only

I am using Visual Studio Community 2019 Version 16.71 over a Pulse Secure VPN. I have 3 machines I work from: 2 laptops and one deskside all running Windows 10 Version 2004. The laptops work fine but after returning from a vacation, the deskside computer started throwing the error: "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication." This happens with all the apps I work on for the University and all for the initial logon portion of the app connecting to the University's SQL server.
I use runas with my University AD credentials for both VS and SSMS.
The deskside still connects to the SQL servers just fine with SSMS so it does not seem to be the VPN or a Windows issue. At first I thought it was just the current app I was working on which is quite old but it happens with every app we have on our TFS server from Windows Forms, MVC and CORE.
Make sure your are using the correct username AND password when using runas.
Make sure you are using /netonly in your runas command
OR
If you are choosing to not use /netonly and are relying on Windows Credential Manager ensure the credentials you are relying on to connect are still valid. Perhaps your password has changed since you returned from vacation?
See answer by Mister Magoo for more information on using runas https://dba.stackexchange.com/questions/66014/connect-to-sql-server-with-windows-authentication-in-a-different-domain

PowerShell AD on server or desktop?

I'm starting out on creating PowerShell scripts for my company. I'm new the the platform and I plan on creating scripts for AD tasks
If im creating scripts for AD should I be able to run the script on any machine in the domain or does the script have to be run on a machine that is the active directory server?
I don't mind running the script on the server but for testing and creating I would rather run it on my desktop for development and testing
any incite on this?
Assuming you're using the activedirectory powershell module, then the only requirement is that the machine you're running the script on has this module installed.
This module is a windows feature "Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tool > Active Directory Module for Windows Powershell."
On a server OS, this can be simply added as a feature through Server Manager
On a client OS, you will first need to install the Remote Server Administration Tools (RSAT) from Microsoft download centre. Once that is installed, you then install the feature through "Turn Windows Features on or off"
Additionally, if your script has a dependency on this module, you can also place the following line at the top of your script
#Requires -Module activedirectory
Then if you try to run this script on a machine without the activedirectory module, it'll produce an error saying the module is missing. It'll also cause the activedirectory module to be imported if it's not already been imported which is useful on powershell. Refer to about_Requires for more information on the #Requires statement

creating service accounts in windows server 2008 R2

How can I create a service account such as SQL service in active directory on Win server 2008 R2?
I dont know in which part of administrative tools that it can be found.
First Confirm that the Managed Users Service Account Container exists using the MMC Active Directory Groups and Users tool:
Second Use Windows PowerShell to create the accounts by running the two commands in lines steps 5 & 6 below:
Click Start
Click All Progams
click Windows PowerShell 2.0, and
then click the Windows PowerShell icon.
Run the following command: Import-Module ActiveDirectory
Run the following command: New-ADServiceAccount [-SAMAccountName ] [-Path ].
If you omit the parameters, the power shell will provide prompts that allow you to supply the name.
That't all there is to it.

Resources