Is it possible to pull certain information from "Net User Query (Username) /dom" through powershell 5.1? - powershell

I'm taking calls at a Helpdesk, and I use PowerShell 5.1 (in restrained language mode with no access to additional modules), running "net user query (username) /dom" for every call.
I'm trying to create a script that makes this process easier and wanted to create a function with the result that I get, but am unsure how to.
How do I select a specific result that comes from the information once net user query command is completed? such as attribute "Full name" and "account log in status"? Is this possible without having any modules installed?
I was hoping to create a variable from the results of some of the information that is returned and then plug them in to other commands.

Related

EXECUTE AS USER in DB2

We are trying to debug a very old web application that uses DB2.
I would like to run a trace to see what happens when I click on a button but as soon as I try I receive this error:
create event monitor ........ for statement where AUTH_ID='.......' write to table
"USER" does not have privilege to perform operation "CREATE EVENT MONITOR".. SQLCODE=-552, SQLSTATE=42502,
Is evident to me that our user doesn't has enough privilege to run a trace.
In T-SQL there is a way to impersonate another user:
USE AdventureWorks2019
GO
EXECUTE AS USER = 'Test';
SELECT * FROM Customer;
REVERT;
I would like to know if there is the same command in DB2.
The goal is to try to run something like SQL Server Profiler for DB2 and sniff the queries.
Yes, I already tried to run GRANT DBADM ON DATABASE TO USER E.....O and of course the system replied:
"E.....O" does not have the privilege to perform operation "GRANT".. SQLCODE=-552, SQLSTATE=42502, DRIVER=3.69.56
We are stuck and we cannot move because we cannot know how the queries work. Asking more privileges to our user is not an option as we are migrating a customer from a competitor to our side.
What I'm trying to do is a sort of privilege escalation without committing any crime.
I also taught about connecting to the DB2 database from SQL Server and use PolyBase but as far as I know such feature only allows me to query and I cannot sniff the parameters.
Db2 has a couple of ways to "impersonate", but all within the security architecture and fully audited.
I would recommend checking out "Trusted Context", basically adding privileges or switching roles based on predefined connection properties.
Another option is to look into SET SESSION AUTHORIZATION (also known as SET SESSION_USER). It switches the SESSION_USER to a different user ID.
As said, that works with the proper privileges and the security admin involved.
Depending on what you want to inspect, db2trc and other command could be of use, too.

How can I use the PowerShell command "Get-AdminPowerAppsUserDetails" for ALL the users

I need to get (in PowerShell) the las time a user used a PowerApp.
I can get that information from the command Get-AdminPowerAppsUserDetails, but that command gives you the data of only one user, and the output is only directed to a file (that´s the way the command works).So If I want the data of all the users in the tenant, I need to create a loop through the users list, call that command for every user, and I must create an output file for every user. Finally I have to concatenate all the users in a single file, and then parse the info.
Is there a better way to get that information instead of calling Get-AdminPowerAppsUserDetails for every user and get those huge amount of files?

Microsoft Graph API query parameters via powershell not recognized

I've registered an app using the Azure AD portal which I am successfully accessing using invoke-webrequest from a Powershell script. The app tries to list signins but is returning up to the limit of 1000 signin objects. When I try to use query parameters to restrict the fields and amount of data returned, the web request returns an error saying that the AllowedQueryOptions and EnableQueryAttributes need to be updated for the parameters used, eg. select, top, skip. I've tried v1.0 and beta APIs without success.
Is there a way to manipulate these options via powershell so that the query parameters are recognized? I've seen some references to OAuth and ASP.NET Core to do this. Is powershell the "right" way to automate signin retrieval? Will this functionality to manipulate query options ever come to powershell?
Cheers,
-Emanuel
As you mentioned in comments, if it is unnecessary for you to use graph api, I think use Powershell command is an option for your reference.
You can use this command in your Powershell:
Get-AzureADAuditSignInLogs
If you want to use query parameters to restrict the fields and amount of data returned, you can refer to the sample as below:
Get-AzureADAuditSignInLogs -Top 5 | Select-Object -Property Id, UserDisplayName
Hope it helps~

Retrieve all accesses from a certain group/project in MicroStrategy

For audit purposes, I am in need of an export from MicrcoStrategy -that could retrieve to a .csv for example- all accesses from a certain group/project, so I can match´em with a report from Active Directory. Is there any way?
Thanks!
I believe Command Manager has a way to do this. Command Manager has a built-in list of command that you can run against your projects/I-server/etc. There should be something like LIST ALL PRIVILEGES ... or LIST ALL PERMISSIONS ... as a part of that.

Can't create user with name like "DOMAIN\name" in Transact-SQL scenario

I have the MS-SQL server and some jobs running every day on it. I can't make one instruction to work correctly in theese tasks:
CREATE USER "DOMAIN\username"
Job fails at this step with "syntax error" message. But if I try to perform the same code in a query manually, everything works perfectly. Job also works fine if executing smth like:
CREATE USER "username"
without backslash symbol.
Specified domain- and user-names are correct and exist. Login for user "DOMAIN\username" already created and appeared in the list of all server logins.
All manipulation were performed via SQL Server Management Studio 2008 R2.
Help me, please, to solve this issue.
Need square brackets:
CREATE USER [DOMAIN\username]
In practice it's safer to use [ and ] (not ") for all identifiers because of vagaries of SET QUOTED_IDENTIFIER